What is Variable?
If you have never programmed before, you may wonder what the term variable means. A variable is a small section of a computer’s memory that you give a name to.
There many different type of data that you might want to be able to store into a variable: numbers, words, dates, and many more.
An integer is a whole number – that is, a number with no fractional portion. For Example 1, 7, 9 and -5 are all integer, but 2.1, 0.3, and -6.1 are not.
Two other data types are related to the integer: bytes and long. A long can store larger range of number than an integer. A byte store fewer.
Floating-point number may have a decimal. 1.5, -3.4, 4.3 and even 5.0 are all floating points numbers. It is important to note, however, that although integers are stored exactly, that is not necessarily true of floating-point numbers. Floating-point numbers are often rounded or truncated to fit into the space allotted for them.
A String can hold any sequence of letters, numbers, and symbols. Strings are distinguished from code, variable name, and numbers by putting them between double quotation marks.
“My name is Adi”, “20kph”, and “2008”These are all possible strings. Even the empty string ” ” can be treated like a string in most case.
A nice feature of VBScript that is missing in other programming languages is its date handling. Although it is possible to represent the date using string and /or integers, this variable type simplifies thing. A date variable can hold either a date or time, and VBScript’s various date functions and operators make the formatting and printing of date related information easily.
A Boolean variable may hold a value of either True or False. Boolean variables are generally used when a decision needs to be made. The value of variable can determine which of two actions should be taken.
What does it meant to Declare a Variable ?
Many programming language requires that, before you use a variable of different types of data you intent to put into the variable and what you want it to be called. For example, in the C++ programming language, you might say
my_variable = 2;
The first line tells system that you want to use a variable that you will call my_variable, an that you want to be able to put integer data into it.
Declaring Variables with Option Explicit
<%@ Language=VBScript %>
<% Option Explicit %>
<% Dim myfirstvariable
myfirstvariable = 2%>
<BODY> The Variable named “myfirstvariable” has a value of
Style Guidelines on Variable Names
Certain conventions are generally followed by programmers. These conventions are not outright required by the system, but they made it easier for you to program and make it easier for others to read your code. Declare all variables at the top. If even after using good names, you have trouble remembering what you called a particular variable.
Suggested Type Prefixes for Variable Names: