Академический Документы
Профессиональный Документы
Культура Документы
2012
IF Condition
You can make a choice on your code depending what happens if the condition is met.
Program 1:
Check if username and password is correct in the login form
Pseudocode
VB.NET
PROCEDURE OK_Click()
MsgBox("Authentication successful")
End If
End Sub
END PROCEDURE
Page 1
2012
Program 2:
Allow a user to enter their age. Then check if the input value is less than 50. If the condition is
true, then display a message Your Age is less than 50.
Pseudocode
VB.NET
PROCEDURE btnAge()
Page 2
2012
IF...ELSE Condition
You can make choices in your code depending on what happens if one condition is met, and what
happens if the condition is not met.
Program 1:
Check if username and password is correct in the login form and display messages
Pseudocode
VB.NET
PROCEDURE OK_Click()
MsgBox("Authentication successful")
Else
'if passowrd is not correct display error
MsgBox("Invalid username or password")
End If
End Sub
ENDIF
END PROCEDURE
Page 3
2012
Program 2:
Allow a user to enter their age. First you check if your age is less than 50. If the condition is true,
display a message Your Age is less than 50 and anything else display a message Your age is
more than 50.
Pseudocode
VB.NET
PROCEDURE btnAge()
ELSE
DISPLAY Your Age is more than
50
ENDIF
End Sub
END PROCEDURE
Page 4
2012
CASE Condition
Youre using Select Case conditions when you have to get a value from the user and respond in
several different ways. Basically, it tests an expression, determine which of several cases it
matches, and execute the corresponding Visual Basic code.
Program 1:
Allow use to calculate GCSE grades based on student marks
Pseudocode
VB.NET
PROCEDURE btnCal_click()
2012
Case Is >= 80
Return "A"
>=80:
DISPLAY " A
>=70:
DISPLAY " B"
>=60:
DISPLAY " C"
>=50:
DISPLAY " D"
>=40:
DISPLAY " E"
>=30:
DISPLAY " F"
>=20:
DISPLAY " G"
ELSE
DISPLAY "Ungraded"
ENDCASE
END FUNCTION
Page 6
2012
Program 2:
Allow a user to enter their age. Depending on the input value:
Pseudocode
VB.NET
PROCEDURE btnAge()
Page 7
2012
Page 8