Forum Moderators: open
Temp = Request("Data")
Do I need to add a DIM statement first?
DIM Temp
Temp = Request("Data")
It seems to work without it but perhaps I'm creating some larger issue overtime or with load such as an Internal Server Error?
And if I use the DIM statement will I need to later remove the variable with:
Set Temp = Nothing ?
Thanks,
You might want to also include option explicit, which requires that you declare the variables that way.
If you don't declare the variables first, they will instantiate, but you run the risk of making errors with typoes. for instance, if you say:
temp = 16
and want to use that later, in a computation, you might type this:
timp = 18
and you'll have both variables out there.
and you'll have both variables out there
To prevent such things from happening put a "option explicit" statement before any ASP code. This statement means that you have to explicitly declare variables with Dim before you can use them. So if you have declared "Dim temp" but later write timp=18, it gives you an error.
And if I use the DIM statement will I need to later remove the variable with:
Set Temp = Nothing?
No, you need to do this only for objects for which you have alotted memory previously with the "set" statement. Say,
set myobj=server.creatobject("blah.blah")
to free memory when you are done with it,
set myobj=nothing