Hi,

How can I get this working!?

I have three integers. I want the highest one to appear in textbox1 when the user clicks command1. I keep getting a 'If missing' error. I'm sure I don't have to use the If statement? Is there some way of looping? I'd appreciate if you could show me what's wrong with my code.

Thanks!

'Three labels, a command button and textbox

Dim rfirst As Integer
Dim rsecond As Integer
Dim rthird As Integer


Private Sub Form_Load()
Randomize
rfirst = Int(Rnd * 20)
Label1.Caption = rfirst
rsecond = Int(Rnd * 20)
Label2.Caption = rsecond
rthird = Int(Rnd * 20)
Label3.Caption = rthird
End Sub


Private Sub Command1_Click()
If rfirst > rsecond Then
If rfirst > rthird Then
Text1 = rfirst
End If
If rsecond > rfirst Then
If rsecond > rthird Then
Text1 = rsecond
End If
If rthird > rfirst Then
If rthird > rsecond Then
Text1 = rthird
End If
End Sub