answersLogoWhite

0

An IF statement simply checks if an argument is true or not, then it executes one block of code, or else it executes another block of code.

It is not limited to visual basic, and you utilise this function in real life every hour of every day, probably hundreds of times a minutes, it is a simple logical statement.

If Then

Breathe

Else

Don't Breathe

End If

When used in a programming sense the only thing that becomes more complicated is the argument, instead of obvious real life arguments often they become comparisons or complicated calculations which evaluate to true or false.

For example, a program needs to know if the user wants to proceed or not, so the programmer has decided this is a good time to ask the user and so he will display a message box to them with yes or no written on it, and find out if they want to continue.

(Note: MsgBox displays a box on the users screen, YesNo tell it what buttons to have on it, if the user clicks yes it returns a value of 6)

If MsgBox("Continue?", MsgBoxStyle.YesNo) = 6 Then

Else

End If

In Visual basic all ifs much have an end if at the end but an else is not required.

User Avatar

Wiki User

14y ago

What else can I help you with?