Site hosted by Angelfire.com: Build your free website today!

‘If... Then...’ Help Page

 

This is going to be a fairly small page, there isn’t much that I can explain if you truly don’t understand this... I’ll try though. Here we go...

The If... Then statement is easy. It means that:

                          

If (this happens) Then

                                    (This would be the result)

                                    End If

 

         Lets do a hypothetical program. It’s going to have message boxes to answer instead of labels though...

 

                                             If intGuess < 1 Or intGuess > 10 Then

                                                      MsgBox “Guess out of range”

                 

This is the simple way: If the guess that the user of the program had guessed was less then one Or greater then ten Then a message box would pop up and say that the guess was out of range. That is what this piece of code means.

                 

                 

 

ElseIf intGuess = intSecretNum Then

MsgBox “You guessed it!”

                 

This is just as simple as the first part : ElseIf the guess was the secret number that the computer had chosen Then a message box would pop up and tell the user that they had guessed the secret number.

 

 

 

ElseIf intGuess < intSecretNum Then

MsgBox “Too low”

 

This is as easy as the first ElseIf statement: ElseIf the user guessed lower then the secret number Then a message box would pop up and tell the user to try again, the guess was too low.

 

 

 

Else

MsgBox “Too high”

End If

 

This is just an even more simplified way of saying: if the program gets anything Else that is not the number, out of range or to low Then a message box would pop up and tell the user that the number s/he guessed was to high. The EndIf is just telling the program that this statement is over and has no other things to worry about.

 

 

 

Back

 

Home