English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

How do you check two numbers - within a tolerance limit ., for example if one label caption says 244, another 245 ., and another 356 ., how can you write code to highlight 244 and 245 ., as they are different by one number ., is there a similar way to pick out dates ., by comparing ., for example ., 4 Feb, 8 Feb, 9 Feb and 15 Feb ., how can you code so that 8 and 9 feb are highlighed or picked out? Any way all this is possible? would save me a lot of work ., as i have to literally look through 1000's of numbers each day to see if there are any that match or are close to each other ., and it drives me crazy!!!

2007-02-09 05:46:22 · 5 answers · asked by indirakshee2001 1 in Computers & Internet Programming & Design

5 answers

How about a simple conditional like:

IF [number] >=243 AND <= 245 THEN
do whatever you need to do
END IF

Same thing with the dates, though you'd use the DATEDIFF function and specify the range that way.

If you set up a text box to enter the search data then it could be something like this:

dim TestNumber, LowRange, HighRange as integer

TestNumber = textbox1.text
LowRange = TestNumber - 1
HighRangeRange = TestNumber + 1

For x = 1 to EOF
IF [column you're checking] >=LowRange AND <= HighRange THEN
do whatever you need to do
END IF
NEXT

hope that helps

2007-02-09 06:18:42 · answer #1 · answered by rod 6 · 0 0

I know I'm not giving you code here, but you have to understand your solution before you can begin coding it.

Read all the numbers, sort them, loop through your collection comparing the previous number to the current number. If the difference is less than or equal to the tolerance, then you have found a match. Same thing for dates, except you have to do a datediff instead of a subtraction.

Hope that makes sense.

*edit*

this will be much faster than looping through again and again as suggested above.

2007-02-09 14:16:04 · answer #2 · answered by javier 2 · 1 0

It is possible. I admit I am not exactly sure how to do this but here is a suggestion.

{I assume you are using vb6}

First,Try putting all the numbers in an array.

dim numbers () as array
' code to add the numbers to the array


Second, try comareing the first agianst the others and repeating this process with something simalar to this:

Dim t as interger
dim u as interger
Dim x as interger
Dim y as interger

for t = 1 to TN ' TN is the amount of numbers in all.

X = numbers (t)

for u = t+1 to TN

Y = numbers(u)

if y = x or y = ( x + 1 ) or y = ( x - 1 ) then
'code for what you want it to when a mach is found here
end if
next
next

If you need anymore help please e-mail me at jsurfer200@yahoo.com

Hope it help. LLAP!

2007-02-09 14:09:02 · answer #3 · answered by James R 2 · 0 0

most efficient way to do this is definitely to first sort the numbers and thereafter check for the tolerance that you need.

Same goes for the dates - using the date function to examine for the tolerance.

It's easy just start coding and you will be excited once you get your answers.

2007-02-09 14:31:25 · answer #4 · answered by optimist 2 · 0 0

check out http://www.pscode.com for great sample codes

2007-02-10 00:19:09 · answer #5 · answered by Richard H 7 · 0 0

fedest.com, questions and answers