answersLogoWhite

0


Best Answer

*NOTE*: The answer to your above question is to use the DIM statement...which means DIMension; you use it to formally declare VBScript variables *before* using them; and, this is meant to set aside sufficient memory space to use the variable in.

EXAMPLE 1/VBScript code...

DIM intX

DIM intY

DIM intTotal

intX=1

intY=2

intTotal=intX+intY

MsgBox(intTotal)

=====

The way to make absolutely certain that each variable has already been declared *before* using it...is to use the Option Explicit statement which is usually written at the start of the program...

EXAMPLE 2a/VBScript code...

Option Explicit

DIM intX

DIM intY

DIM intTotal

intX=1

intY=2

intTotal=intX+intY

MsgBox(intTotal)

intZ=2

MsgBox(2)

...in this case, the program stops when it reaches the variable called: intZ; complaining that this variable is 'undeclared'.

If you were to add DIM intZ...*before* using the variable name...then, the program should work ok; as in the following example.

EXAMPLE 2b/VBScript code

Option Explicit

DIM intX

DIM intY

DIM intZ

DIM intTotal

intX=1

intY=2

intTotal=intX+intY

MsgBox(intTotal)

intZ=2

MsgBox(2)

=====

Finally, this last example shows that you can use the DIM statement to declare not only a 'single' variable, alone, on each line; but, you can also use it in a more compact form by declaring 'multiple' variables all being written on the one same line; with each of these variables being seperated by a comma.

EXAMPLE 3/VBScript code...

Option Explicit

DIM intX,intY,intZ,intTotal

intX=1

intY=2

intTotal=intX+intY

MsgBox(intTotal)

intZ=2

MsgBox(2)

User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

9y ago

to declare a Variable you use 'Dim' then you name the Variable so for example 'Dim Var1'

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: What VB Script keyword is used to formally declare a variable used by the script before trying to use it?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Which symbol is used with a variable to indicate to the script that you are reading the contents of that variable?

Which symbol is used with a variable to indicate to the script that you are reading the contents of that variable?


How do you equate a php variable to a javascript variable?

Ideal thing would be to retrieve the value from PHP using AJAX and then assigning it to a java script variable. Thereafter compare it to the java script variable that is already present.


What is a javascript variable?

A variable in JavaScript is an identifier that provides a storage location used to store a data value. The data stored at a particular location in memory. That we accessed by using the variable name. In JavaScript programs, a script will have to store the bits of information temporarily. It needs to do its work. It can store this data in variables. In other words, A variable is a symbolic name given to a location in the computer memory. Where we store the value, which can be used in the program. The value of the variable can change during the execution of the program. It may take different values at different times during the execution of the program. The name of the variable that we choose must be meaningful to understand, what it represents in the program. For example var Price = 100; Rules to follow: The name of the variable can contain a letter, digits, underscore(_), and dollar sign($). They must begin with a letter, not with a digit. Uppercase and Lowercase are distinct. That means the variable Total is not the same as total or TOTAl. It should not be a keyword. White space does also not allow. Variable can be any length. Hope this helps. Thank you


How do you control a new window you created with Java Script code?

You assign the window you opened to a variable. For example: var myWindow=window.open("http:\/\/mysite.com/");


How to convert a string into an integer in javascript?

In C# you can do that in the following way Convert.ToInt32(yourStringHere), for instance Convert.ToInt32("wikianswers"). But not all string can be converted to int type. If it happens compilator will throw the exception converting error which you can handle using structure try { ...//your code } catch (Exception) { ... //your code in the case of the exception }

Related questions

Which symbol is used with a variable to indicate to the script that you are reading the contents of that variable?

Which symbol is used with a variable to indicate to the script that you are reading the contents of that variable?


How will you defined variavble in vb script?

To define a variable in VBScript, you use the keyword "Dim" followed by the name of the variable. You can name the variable any string so long as itBegins with a letterDoes not contain a period (.)Is not longer than 255 charactersSo "tom" is a valid variable name, but "tom.d" is not.To assign value to the variable, you use the assignment operator (=)Dim coolWebSite = "Answers.com"The variable "coolWebSite" will now contain the string "Answers.com"


What is a javascript variable?

A variable in JavaScript is an identifier that provides a storage location used to store a data value. The data stored at a particular location in memory. That we accessed by using the variable name. In JavaScript programs, a script will have to store the bits of information temporarily. It needs to do its work. It can store this data in variables. In other words, A variable is a symbolic name given to a location in the computer memory. Where we store the value, which can be used in the program. The value of the variable can change during the execution of the program. It may take different values at different times during the execution of the program. The name of the variable that we choose must be meaningful to understand, what it represents in the program. For example var Price = 100; Rules to follow: The name of the variable can contain a letter, digits, underscore(_), and dollar sign($). They must begin with a letter, not with a digit. Uppercase and Lowercase are distinct. That means the variable Total is not the same as total or TOTAl. It should not be a keyword. White space does also not allow. Variable can be any length. Hope this helps. Thank you


How do you equate a php variable to a javascript variable?

Ideal thing would be to retrieve the value from PHP using AJAX and then assigning it to a java script variable. Thereafter compare it to the java script variable that is already present.


How do you do the pass the variable value to the query in same php page?

To pass PHP Variable value in Jquery simpley echo that variable : Eg <script> var jQueryVariable=<?php echo $anyVariable?> </script>


Which superglobal variable holds information about headers paths and script locations?

$_SERVER is a PHP super global variable which holds information about headers, paths, and script locations.


Why use awk -v command?

This is used when you want to give a variable in an awk script a value before the script starts executing, even before the BEGIN block. You would do this on the command line if the variable needs different values for different executions rather than hardcoding it in the awk script itself.


How do you properly play a script in game maker?

script_name(arguments); If you have arguments, like what the V variable should be, put them in there. Script_name should be replaced with the name of your script.


What variable will capture the content of the argument passed to a script at the command line?

If you read your book, you will find the answer!


Can you please show sample of Debut party script?

There are many samples of this available online. Doing a keyword search can bring up examples for you to use.


What variable will capture the contents of the second argument passed to a script at the command line?

If you read your book, you will find the answer!


How do you list all files from directory in PHP4?

Here is a small script that will get the files from the $folder variable using a dir function.