|
|
 |
 |
 |
' The IF statement is the first thing i learned in programming.
' IF? is your questions to the application, so that you can
' decide what is going to happen next..
' if a counter is 10 then set it back to 0
' if you don't have any money left, you can't buy that dvd-player.
' if your character fall more than 3 units in a game, then he loses energy etc.
Dim num As Integer
Dim strReply As String
Private Sub Form_Load()
'Ask our question when the program loads
Label1.Caption = "How many cars do you have?"
End Sub
Private Sub Command1_Click()
num = Int(Text1.Text) 'Input
If (num > 0) Then
strReply = "You have a car!"
Else
strReply = "You don't have a car!"
End If
If (num > 1) Then strReply = "Are you rich!"
'display our comment
Label1.Caption = strReply
End Sub
'sometimes you just need one if statement
'IF (?) Then do this
'IF (?) Then
' do this
'End If
'sometimes you ned two or more if statements
'If (question1?) Then to this
'If (question2?) Then to that
'sometimes it is easier to use if else
'If(question1?) Then to this Else do that
'If(question1?) Then
'to this
'Else
'do that
'End If
'sometimes it is easier to use if else if
'If(question1?) Then
'to this
'Else If
'do that
'End If
' I have tried to demonstrate different ways to use if tests
' It all depend on the "situation", and how you prefer to do your programming...
|
 |
Visual Basic Source Code |
I hope you found this Visual Basic tutorial useful!
Don't forget to mention Apron Tutorials in your References!
Best Regards
Ronny André Reierstad
|
|
|