Download presentation
Presentation is loading. Please wait.
Published byHartono Setiawan Modified over 5 years ago
1
4a- If And Else Lingma Acheson CSCI N331 VB .NET Programming
Department of Computer and Information Science, IUPUI
2
If Statement Sometimes we want things to happen only when a certain condition is met, e.g. in the Calculator project, only perform the division when the second input is not 0. Structure: If condition1 Then statement1 statement2 … End If Meaning: If condition1 is true, statements will be executed, otherwise, nothing happens. E.g. If dblInput2 <> 0 Then dblResult = dblInput1 / dblInput2
3
If/Else Statement Sometimes we want to say “If condition1 is true, do this, otherwise, do that.” E.g. If the second input is not 0, perform the division, otherwise, telling the user “The second number is 0, unable to perform the division.” Structure: If condition1 Then statement1 statement2 Else statement3 statement4 End If If condition1 is true, statement1 and statement2 will be executed, otherwise, statement3 and statement4 will be executed.
4
If/Else Statement End If E.g. If dblInput2 <>0 Then
dblResult = dblInput1 / dblInput2 Else MessageBox.Show(“The second input is 0, unable to perform the division.”) End If
5
If/Else Statement Comparison operators:
=, <>, <, >, <=, >=
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.