Expressions are simply a statement where you have included a calculation that should end as a result (numerical, character or as a boolean also).
Example of expressions are given below:
5+6 (Sample Numeric Expression)
x+y
"Nidal" & " Arabi" (Sample String expression)
x.ToString() + " Is the Number of Children"
X > Y (Sample Boolean Expression)
Statements on the other hands are the building block of the programming when dealing with VB.NET
They are made up of (or combination of)
- keywords-i.e. reserved words for the VB.NET language like Dim, If, Else, etc...
- Operators (Explained in previous post)
- Variables (Explained in previous post)
- Constants (Will Be explained when need arise...But think of them as variables with a specific single value that should not be changed once assigned)
- Expressions (Explained Above)
There are three main different categories of statements
- Declarative: When you define a variable like Dim EyeColor as String
- Assignment: When You assign a new value to a variable like EyeColor = "Brown"
- Executable: A statement that usually instruct the computer to do something special like If A > B Then MessageBox("A is Greater then B")
To summarize
- Each statement is simply a command to execute
- Each statement can be on its own line. Statements can also be grouped on a single line by separating them with a column. Example of two statements together would be X = X + Y : Y = Y * 2
- Sometimes you may also need to span a single statement on two lines. You can do this simply by using the underscore character. Example: Gross Income = _
TotalIncome – Tax. - A sequence of statement can make you programs do beautiful things. :)
No comments:
Post a Comment