vbscript-integer-divide

OPERATOR: \


Implemented in version 1.0

\

The \ operator divides two numbers and returns an integer (fixed-point). Each number can be either floating-point or fixed-point.

This operator works by rounding the values of the supplied operands to integers (if necessary) before performing the calculation and only returns an integer with no decimal representation (truncated).

This first example requires no rounding of the operands and returns ‘6’ (‘6.25′ truncated).

Code:
<% result = 25 \ 4 %>

Output:
6

This next example demonstrates the ‘pre-rounding’ of the operands; the actual values used for the calculation eqate to ’35\6′ which returns ‘5’ (‘5.833r‘ truncated).

Code:
<% result = 35.4 \ 6.01 %>

Output:
5

Compare the previous example to the next which returns ‘6’ because the first operand has been rounded internally to ’36’ before calculation.

Code:
<% result = 35.9 \ 6.01 %>

Output:
6

vbscript-multiply

OPERATOR: &


Implemented in version 1.0

&

The & operator is the preferred operator for concatenating strings. However, the + operator may also be used for concatenation.

Code:
<% cheese= » is made of blue cheese. » %>
<% sentence= »The moon » & cheese &  » Mice like blue cheese. » %>

Output:
The moon is made of blue cheese. Mice like blue cheese.

vbscript-concatenate

OPERATOR: &


Implemented in version 1.0

&

The & operator is the preferred operator for concatenating strings. However, the + operator may also be used for concatenation.

Code:
<% cheese= » is made of blue cheese. » %>
<% sentence= »The moon » & cheese &  » Mice like blue cheese. » %>

Output:
The moon is made of blue cheese. Mice like blue cheese.

vbscript-Dim

STATEMENT:  Dim 


Implemented in version 1.0

Dim 

The Dim statement allows you to explicitly declare one or more new variables and to allocate storage (memory) space. 

While you do not have to use Dim to create new variables in VBScript, the wise programmer prefers to use Dim. In fact, many programmer purposely include theOption Explicit statement in all of their VBScript programs which mandates that all variables be explicitly declared. 

Code: 
<% Dim myvariable %> 
<% Dim OneVar, TwoVar, ThreeVar, FourVar, MoreVar, EvenMoreVar %> 

Dim can also be used to create static (fixed) and dynamic arrays. 

A static array has the number of elements declared by the Dim statement. However, you must remember that the elements in an array are numbered starting at zero. Consider the following Dim declaration. It creates a static array containing six elements that are numbered 0, 1, 2, 3, 4 and 5. 

Code: 
<% Dim SixElementArray(5) %> 

A dynamic array is declared using empty parentheses. At a later point in your program, you can use the ReDim statement to declare the number of dimensions and elements. In fact, you can redeclare a dynamic array as many times as you desire. 

Code: 
<% 
Dim SomeArray() 
 
ReDim SomeArray(22) 
 
ReDim SomeArray(500) 
%> 

Arrays can also have up to sixty dimensions. For example, the following code creates a three dimensional array. The first dimension has 23 elements, the second dimension has 15 elements and the third dimension has 201 elements. Therefore, there are a total of 23x15x201 = 69345 elements in this array. 

The number of dimensions that you can create is limited by the available memory. If you exceed the available memory while declaring an array, you will get an error message. 

Code: 
<% Dim ThreeDimensionArray(22, 14, 200) %>