Visual Basic 2005 Guide
If Statement - Programming Tasks
1. Write a program to work out someone's exam grade based on their mark. The user should enter an exam mark out of 100. A mark of less than 50 is a fail. More than 50 gets a pass.
2. You can get your program to test whether to things are true before running the relevant code. For example, if a nightclub bouncer has been instructed to only allow admission to females aged 18 or over, your program would need to make sure that both things are true. You do this using the And keyword.
For example, If (intAge>=18) And (strSex = "f") Then
Write a program that tells the caveman what to do.
3. You can use the keyword Or to test whether one of two conditions is true. Imagine a scenario where the members of a sports team get an award if they score more than 10 goals or if they play more than 12 games.
For example, If (intGoals>10) Or (intGames>12) Then
Make it happen.