Tuesday, April 26, 2011

Visual Basic Statements and Expressions


    The simplest statement is the assignment statement.  It consists of a variable name, followed by the assignment operator (=), followed by some sort of expression.
     
      Examples:
     
            StName="Saman"
            Speed=60
            Energy = Mass * LIGHTSPEED ^ 2
            NetWorth = Assets - Liabilities
     
The assignment statement stores information.

·         Statements normally take up a single line with no terminator.  Statements can be stacked by using a colon (:) to separate them.  Example:

StartTime = Now : EndTime = StartTime + 10

(Be careful stacking statements, especially with If/End If structures.  You may not get the response you desire.)
     
·         If a statement is very long, it may be continued to the next line using the continuation character, an underscore (_).  Example:

Months = Log(Final * IntRate / Deposit + 1) _
/ Log(1 + IntRate)

No comments:

Post a Comment