Expressions are the pieces of code that produce values. They are used in assignments, conditions, function arguments, and return statements.
<expression>([<arg>[, <arg>...]])
<expression>.<identifier>
<expression>\<identifier>
<expression>[<indexExpr>[, <indexExpr>...]]
Postfix operations can be chained, such as foo.bar[1].baz(2). Both . and \ are recognized for member access. . is the preferred modern style.
Enum members are accessed with EnumName.MemberName. The bare enum name (for example Direction) is a type name and cannot be used by itself as a value expression.
If you are learning arrays for the first time, read Arrays for a step-by-step explanation of declarations, indexes, and common mistakes.
New <TypeName> allocates a new object for a user-defined Type.
Type Player
Field Name As String
Field Score As Integer
End Type
Dim currentPlayer As Player
currentPlayer = New Player
A comparison checks whether one value matches or relates to another value. The result of a comparison is always True or False.
= means equal to<> means not equal to< means less than<= means less than or equal to> means greater than>= means greater than or equal toYou can compare variables to variables, variables to constants, or more complex expressions.
score = 10
health <= 0
playerX > enemyX
lives <> maxLives
(coins + bonus) > targetScore
Use logical operators when a condition depends on more than one test.
And means both sides must be TrueOr means either side can be TrueNot flips True to False and False to Truescore >= 100 And lives > 0
health <= 0 Or timeLeft = 0
Not finished
(x > 0 And y > 0) Or debugMode
When a condition starts to look complicated, add parentheses to make the grouping clear.
From lowest to highest:
Parentheses let you force a different order when needed.