VB Script
  Variables
  IF Statement
  Select Case
  Loops
  String Manipulation
  Sub Procedures
  Functions
VB Script Variables
 
Definition: is a section of memory that is allocated a name by the programmer.
 
Syntax:
DIM variablename
 
Examples:
DIM strName
DIM strAddress, strCity, intTelephone
strName = "John"
strAddress = "248 Somewhere St"
strCity = "New York"
intTelephone = 4164527854
 
In VB Script all variables are created with the data type variant. A variant is a special data type, it will change to different data types depending on the data it is holding. If for example strName = "John" it will be a string. If trying to set a variable equal to a date use # around the value. Example DateTime = #12/10/2001#
 
The some different subtypes that the variant data type may act like:
Subtypes Description
Byte Whole number in the range of 0 to 255
Integer Whole number in the range -32,768 to 32,767
Long Whole number in the range 2,147,483,648 to 2,147,483,647
Single Single-precision floating-point number with 6 digits of accuracy
Double Double-precision floating-point number with 14 digits of accuracy
Currency Decimal Fractions, such as dollars and cents
Date An eight-character date
Boolean True or False values
String Alphanumeric data: letters, digits and other characters
 
Some functions to use to determine the type of data held by a variable:
Function Description
TypeName(variable) Will return the subtype of a variable.
If a variable is holding a string it will return "String"
If a variable is holding a double it will return a "Double"
isnumeric(variable) If the value in a variable is numeric it returns "True" else "False"
Note: Even if the variable subtype is a string but the string's value is a number it will return "True"
 
Some Data Type Conversion Functions:
Function Description
Abs Returns the absolute value of a number.
Asc Returns the ANSI character code of a character.
Chr The opposite of Asc. Returns a character from a ANSI character code.
CBool Converts a variable into a Boolean subtype.
CByte Converts a variable into a Byte subtype.
CCur Converts a variable into a Currency subtype.
CDate Converts a variable into a Date subtype.
CDbl Converts a variable into a Double subtype.
CInt Converts a variable into a Integer subtype.
CLng Converts a variable into a Long subtype.
CSng Converts a variable into a Single subtype.
CStr Converts a variable into a String subtype.
 

Copyright 2002 VisualTech Components. All Rights Reserved.