' 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.PublicClass Form1
Inherits System.Windows.Forms.Form
Dim num AsIntegerDim strReply AsStringPrivateSub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) HandlesMyBase.Load
'Ask our question when the program loads
Label1.Text = "How many cars do you have?"EndSubPrivateSub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
num = Int(TextBox1.Text) 'InputIf (num > 0) Then
strReply = "You have a car!"Else
strReply = "You don't have a car!"EndIfIf (num > 1) Then strReply = "Are you rich!"'display our comment
Label1.Text = strReply
EndSubEndClass'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 .Net Source Code
I hope you found this VB .Net tutorial useful!
Don't forget to mention Apron Tutorials in your References!