Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » V.B 6.0: Comparing multiple integers
Closed Thread
Old 02-18-2006, 09:41 PM   #1 (permalink)
 
Junior Techie

Join Date: Sep 2005

Posts: 61

jamie7823

Default V.B 6.0: Comparing multiple integers

I just bought a visual basic 6 book. This will be my very first language.

Im in ch 3 of he book and it gives an exercise and wants me to make a script to compare 3 random integers and make it print the smallest and largest of the 3.

X is the largest number of the 3.
y is the smallest of the 3.


is there some way i can compare 1 integer to a list?

this is what i had in mind....

If X>(y,z) then
X=largest
End If

If Y> (x,z) then
Y=largest
End If

If Z>(x,y) then
Z=largest

End If

If X<(y,z) then
X=smallest
End If

If Y< (x,z) then
Y=smallest
End If

If Z<(x,y) then
Z=smallest
End If


Print largest ,"is the largest of the 3 numbers."
Print smallest, " is the smallest of the 3 numbers."


Im aware that my print statement may be out of wack but I'd like to concentrate on the comparisons.

Thank you
__________________
Dell Dimension 3000, Win 2000 pro, BEFW11S4 Linksys router.
jamie7823 is offline  
Old 02-19-2006, 12:36 AM   #2 (permalink)
 
Junior Techie

Join Date: Oct 2005

Posts: 61

Sainath

Default

Try this

Dim L,M,S as Integer
Dim Lt,Mt,St as Boolean
L = Int(Rnd*5)
M = Int(Rnd*5)
S = Int(Rnd*5)

If L > M and L > S Then
Lt = True
End if

IF M > L and M > S Then
Mt = True
End if

If S > L and S > M then
St = True
End if

And so on.

Basically use the Same code you used, One set for finding the biggest, one for finding the smallest, but instead of using brackets, use the AND operator.
Sainath is offline  
Old 02-19-2006, 02:26 AM   #3 (permalink)
 
Junior Techie

Join Date: Sep 2005

Posts: 61

jamie7823

Default

sweet dude thank you ill try that out.
__________________
Dell Dimension 3000, Win 2000 pro, BEFW11S4 Linksys router.
jamie7823 is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On