Simple Comparison

  • Thread starter Thread starter Carlo B
  • Start date Start date
C

Carlo B

I need the program to compare two numbers and although the code below
works I have a feeling that it can be done in fewer lines. Is there a
better way?

Dim first, second, third, var As Integer
Private Sub btnAdd_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnAdd.Click
var = CInt(txtInput.Text)
If var > first And var > second Then
third = first
first = var
If third > second Then
second = third
End If
ElseIf var < first And var < second Then
third = var
ElseIf var > first Or var > second Then
If var > first Then
second = first
first = var
ElseIf var > second Then
second = var
End If
End If
txtOutput.Text = CStr(first & " " & second)
End Sub
End Class
 
Hi Carlo,

If a < b then
messagebox.show("ab" )
else
messabebox.show("ba")
end if

Or do I mis something?

Cor
 
Back
Top