Visual Basic 2005


Add to MY Favorites...

Back to Vicky's Home Page Teaching Home Page Visual Basic 2005 Html For Kids

Formulas

A formula uses numbers, variables, operators and keywords to create a new value.  The value is assigned to a variable.  The formula may look like an equation, but it is an assignment statement.

Profit = Income - Expenses

Profit is the variable which gets the result assigned to it.

The formula is Income - Expenses.  The minus sign is the Operator.

Operators

 

+, -, *, /

 

Math as expected

\

integer (whole number) division

 

MOD

remainder division

 

^

raise to a power

 

&

use to concatenate strings - join strings together

 

 

Using Operators

Operators are used to create a new value which is assigned to a variable.  The equal sign is used, but it really means assign the result to this.

Shortcut statements, like those introduced in C+ are new in VB 2005.  These are a little harder to comprehend intuitively when you read the program, but you can get used to it.

 

Traditional Statements

Shortcut Statements

X = X + 6

X+=6

 

X = X – 6

 

X-=6

 

X = X * 6

 

X*=6

 

X = X / 6

 

X/=6

 

X = X \ 6

 

X\=6

 

X = X ^ 6

 

X^=6

 

X = X & “ABC”

 

X&=”ABC”

 

Math Methods

Here is a partial list of the math methods in the System.Math class, which is a library provided by the Microsoft .Net Framework that taps into the Windows operating system.

ABS(n)            returns absolute value of n

Atan(n)            returns arctangent, in radians, of n

Cos(n)             returns cosine of the angle n, in radians

Exp(n)             returns the constant e raised to the power of n

Sign (n)           returns -1 if n is negative, 0 if n is zero, and +1 if n is positive

Sin(n)              returns the sine of the angle n, in radians

Sqrt(n)             returns the square root of n

Tan(n)             returns the tangent of angle n, in radians

 

To use these, you must have the following statement at the very top of the form’s code.

 Imports System.Math

 
 

 
Another page developed by
vicky@vickywoodard.com
Copyright © 2006 Vicky K. Woodard
All rights reserved
Last updated: 8/17/2006