Statements in Visual Basic
A statement in Visual Basic is a complete instruction that can contain keywords, operators, variables, constants, and expressions. Following are the categories of statements
You use declaration statements to name and define procedures, variables, properties, arrays, and constants. When you declare a programming element, you can also define its data type, access level, and scope.
When the code containing a declaration statement runs, Visual Basic reserves the memory required for the declared element. If the element holds a value, Visual Basic initializes it to the default value for its data type. You can assign an initial value to a variable as part of its declaration, as the following example illustrates.
Assignment statements carry out assignment operations, which consist of taking the value on the right side of the assignment operator (=) and storing it in the element on the left, as in the following example.
v = 42
In the example, the assignment statement stores the literal value 42 in the variable v.
An executable statement performs an action. It can call a procedure, branch to another place in the code, loop through several statements, or evaluate an expression. An assignment statement is a special case of an executable statement. The following example uses an If...Then...Else control structure to run different blocks of code based on the value of a variable. Within each block of code, a For...Next loop runs a specified number of times.
|All times are GMT +5.5. The time now is 07:14.|