Hi there,

I'm sure there's a funkier, shorter, more professional way of doing my quest below, so I'd be grateful if you could let me in on the secret.

Basically, there are 6 textboxes. In textboxes 1 to 5, random numbers from 0 to 20 are loaded on form load event.

Then, when command1 is clicked, textbox6 will say, 'textbox1 is the highest number' (or whichever textbox happens to be the highest).

I'd be very grateful for any help!


Private Sub Form_Load()
Randomize
Text1 = Int(Rnd * 20)
Text2 = Int(Rnd * 20)
Text3 = Int(Rnd * 20)
Text4 = Int(Rnd * 20)
Text5 = Int(Rnd * 20)
End Sub

Private Sub Command1_Click()
If Val(Text1) > Val(Text2) Then
If Val(Text1) > Val(Text3) Then
If Val(Text1) > Val(Text4) Then
If Val(Text1) > Val(Text5) Then
Text6 = "textbox1 is the highest"
End If
End If
End If
End If

If Val(Text2) > Val(Text1) Then
If Val(Text2) > Val(Text3) Then
If Val(Text2) > Val(Text4) Then
If Val(Text2) > Val(Text5) Then
Text6 = "textbox2 is the highest"
End If
End If
End If
End If

If Val(Text3) > Val(Text1) Then
If Val(Text3) > Val(Text2) Then
If Val(Text3) > Val(Text4) Then
If Val(Text3) > Val(Text5) Then
Text6 = "textbox3 is the highest"
End If
End If
End If
End If

If Val(Text4) > Val(Text1) Then
If Val(Text4) > Val(Text2) Then
If Val(Text4) > Val(Text3) Then
If Val(Text4) > Val(Text5) Then
Text6 = "textbox4 is the highest"
End If
End If
End If
End If

If Val(Text5) > Val(Text1) Then
If Val(Text5) > Val(Text2) Then
If Val(Text5) > Val(Text3) Then
If Val(Text5) > Val(Text4) Then
Text6 = "textbox5 is the highest"
End If
End If
End If
End If
End Sub