|Conditional statement.||A line of code that makes a decision.|
|Equality operator.||Checks to see if two peices of data are the same (equal).|
|Relational Operator||Check to see if a relationship between two peices of data is true.|
|If - Then||Runs code if a condition is true.|
|=||An equality operator when used in an If statement.|
|<||Less than. (relational operator)|
|>||Greater than. (relational operator)|
|<=||Less than or equal to (relational operator)|
|>=||Greater than or equal to (relational operator)|
Dim pName As String pName = "Bob" If pName = "Bob" Then Print "You are Bob." Print Print "(press any key)" Sleep End
Dim secretCode as Integer Input "What is the secret code" ; secretCode If secretCode = 12345 Then Print "Yes, that is the secret code. I have to kill you now." Print Print "(press any key)" Sleep End
Dim gold As Integer Dim torchPrice As Integer gold = 50 torchPrice = 25 If gold < torchPrice Then Print "I'm sorry, you do not have enough gold to buy the torch." If gold > torchPrice Then Print "You do have enough money to buy the torch. Happy dungeoneering!" Print Print "(press any key)" Sleep End
' need example for less than or equal to and greater than or equal to
1. A conditional statement checks a condition and then runs code based on whether or not a condition is true or not. The most common conditions tested are :
- a = b : is a equal to b?
- a < b : is a less than b?
- a > b : is a greater than b?
- a <= b : is a less than or equal to b?
- a >= b : is a greater than or equal to b?
Here is the structure of a simple If statement :
- If (condition) Then (code)
- No exercises yet.
page revision: 5, last edited: 02 Jun 2007 02:10