Greater than or Less than

vgersghost

Vgersghost
Local time
Today, 11:00
Joined
Apr 29, 2005
Messages
106
Hello

I have data say enter into twelve controls and after the last item is enter is there a way to compare them against one another to find the larger and smaller numbers without a ton of "IF" statements. I would like to then subtract the two.

I tried Dmax and a few other combinations, but cannot seem to get away form a bunch of "IF" statements.

thank you
 
load them into an array then sort the array.
 
Array ??

I have no idea on how to use array's. I'll look at help, but a little guidance would be nice.

thanks
 
Name your controls with a number in them.

i.e. Control1 thru control2

You can then loop thru each control and do one or two ifs...

Have a look at the help in "for next" statement to see how loops work. I presume you know how to refer to controls if you are allready working with the IFs.

Good luck !
 
I suspect a normalisation issue here. If you have 12 fields in the record that hold data that is similar (which it must be because you are comparing them), then these should exist as 12 records in a new table. Your calculation them becomes pretty simple.
 
Array

Alright I figure out how to fill the array through a loop, using this code (not compete just example)

i = 0
For Each control In Me.Controls
If TypeOf control Is TextBox Then
myarray(i) = me.control.value
i = i +1
endif
next

Where does the Dmax come into play to find the greatest number and Dmin for the smallest in the array?
 
Not, you cannot dmax an array as far as I know, but I never work with an array.

What happens if you do it like this?
i = 0
Minvalue = 9999999
For Each control In Me.Controls
If TypeOf control Is TextBox Then
if me.control.value < MinValue then MinValue = me.control.value
endif
next

That should load the minimum value into MinValue... Is that what you are looking for?
 

Users who are viewing this thread

Back
Top Bottom