I think it is easier on the brain if you break it down further, so you are not mentally doing multiple comparisons every time you write an If clause.
Example using a Button and two TextBoxes:
vb.net Code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim a, b As Integer Integer.TryParse(TextBox1.Text, a) Integer.TryParse(TextBox2.Text, b) Dim oneIsSmall As Boolean = (a < 0 OrElse b < 0) Dim oneIsBig As Boolean = (a > 1000 OrElse b > 1000) If oneIsSmall AndAlso oneIsBig Then MessageBox.Show(String.Format("one is too small and one is too big : {0}, {1}", a, b)) ElseIf oneIsSmall Then MessageBox.Show(String.Format("one or both are too small : {0}, {1}", a, b)) ElseIf oneIsBig Then MessageBox.Show(String.Format("one or both are too big : {0}, {1}", a, b)) Else MessageBox.Show(String.Format("both are within range : {0}, {1}", a, b)) End If End Sub




Reply With Quote