Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
If MyIPAddress = "0" Then
If MyIPAddress = OldIPAddress Then
If MyIPAddress.StartsWith("168.") Then
If MyIPAddress.StartsWith("169.") Then
If MyIPAddress.StartsWith("192.") Then
Debug.Print("all good")
End If
End If
End If
End If
End If
End Sub
Private Sub Button1_Click_1(sender As Object, e As EventArgs) Handles Button1.Click
If MyIPAddress = "0" AndAlso
MyIPAddress = OldIPAddress AndAlso
MyIPAddress.StartsWith("168.") AndAlso
MyIPAddress.StartsWith("169.") AndAlso
MyIPAddress.StartsWith("192.") Then
Debug.Print("all good")
End If
End If
End If
End If
End If
End Sub
Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.
Have a better answer? Share it in a comment.
From novice to tech pro — start learning today.
Open in new window
And would do the same thing, except that And would evaluate *every* condition, whereas AndAlso will "short-circuit" on the first non-true condition. If any condition is False, then there is no reason to check the remaining conditions. In boolean algebra, in order for a boolean and to result in true, every condition must be true. If any single condition is false, then the overall result will be false. This is what "short-circuiting" accomplishes.