Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

which number is smaller?

Status
Not open for further replies.

RobSzar

MIS
Mar 6, 2005
8
US
I have 5 numbers that are always changing, is there an easy way to tell which is the smallest?

var1="110"
var2="154"
var3="100"
var4="160"
var5="130"

this is just an example, the #'s will always be changing, the way I'm doing it now sucks, so much code for such a simple thing, there got to be an easier way

if var1 > var2 the
smallest=var2
else
smallest=var1
end if
if var3 > var4 the
smallest=var4
else
smallest=var3
end if
and so on...
 
Something like this ?
myArr=Array(var1,var2,var3,var4,var5)
smallest=var1
For i=1 To UBound(myArr)
If smallest>myArr(i) Then smallest=myArr(i)
Next

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Perfect! much better then the way I was doing it!


Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top