I had to do the same thing for VB.net, here's the code i used, when a user clicks a button.
Private Sub btnExecise10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExecise10.Click
' Declair my varibles
Dim Number1 As Integer = 1
Dim Number2 As Integer = 2
Dim Number3 As Integer = 3
Dim NumberDisplay1 As Integer = 1
Dim NumberDisplay2 As Integer = 3
Dim NumberDisplay3 As Integer = 2
' While the 3 numbers arn't the same
While NumberDisplay1 <> NumberDisplay2 Or NumberDisplay1 <> NumberDisplay3 Or _
NumberDisplay2 <> NumberDisplay3
Try
' Clear the number to display
Number1 = InputBox("Enter Number 1")
Number2 = InputBox("Enter Number 2")
Number3 = InputBox("Enter Number 3")
' If number 1 is greater than 2 and 3 then number to display for slot 1 is 1
If Number1 >= Number2 And Number1 >= Number3 Then
NumberDisplay1 = Number1
' If number 2 is greater than number 3 number 2 is in the display 2
' And number 3 is to be displayed is in display 3
If Number2 >= Number3 Then
NumberDisplay2 = Number2
NumberDisplay3 = Number3
End If
' If number 3 is greater than number 2 number 3 is in the display 2
' And number 2 is to be displayed is in display 3
If Number3 >= Number2 Then
NumberDisplay2 = Number3
NumberDisplay3 = Number2
End If
End If
' If number 2 is greater than or equal to number 1 and
' If number 2 is greater than or equal to number 2 then
If Number2 >= Number1 And Number2 >= Number3 Then
' Display number 1 as 2
NumberDisplay1 = Number2
' If number1 is greater than number 3
If Number1 >= Number3 Then
' Then number 2 is number 1
NumberDisplay2 = Number1
' And number 3 is number 3
NumberDisplay3 = Number3
End If
' If number3 is greater than number 1
If Number3 >= Number1 Then
' Then number 2 is number 3
NumberDisplay2 = Number3
' And number 3 is number 1
NumberDisplay3 = Number1
End If
End If
' Same as above
If Number3 >= Number1 And Number3 >= Number2 Then
NumberDisplay1 = Number3
If Number1 >= Number2 Then
NumberDisplay2 = Number1
NumberDisplay3 = Number2
End If
If Number2 >= Number1 Then
NumberDisplay2 = Number2
NumberDisplay3 = Number1
End If
End If
' Display the numbers
MessageBox.Show("Top number is: " & NumberDisplay1 & vbNewLine & _
"Middle number is: " & NumberDisplay2 & vbNewLine & _
"Last number is: " & NumberDisplay3, "")
Catch ex As Exception
End Try
End While
' Now we exit because all 3 numbers are the same, display that they are
MessageBox.Show("All 3 numbers are the same!")
End Sub
Might be of some use.