Matt wrote:
<% hour = Request("controlname") %> will yield the following error:
Hour() is a builtin vbscript function. Do NOT use ambiguous words for
variable names.
Microsoft VBScript runtime (0x800A01F5)
Illegal assignment: 'hour'
This is why "hour" should not be used for the variable name.
However, if I declare hour, then it is fine.
No, it is not.
<%
Dim hour
hour = Request("controlname")
%>
Try calling the Hour() function after declaring it as a variable.
dim hour
hour=3
Response.Write(hour(#13:25:00#))
You will quickly see why it is not fine. :-)
Now I realize that it can add much time to your coding if you have to look
up all the variable names you wish to use in online documentation to make
sure you aren't using a keyword. The solution is to use a naming convention
that will guarantee that your variable names never conflict with builtin
names. The convention can be as simple as always prefixing your variables
with the letter "v", vHours instead of hours. Or it can be a little more
informative (as well as making your code more self-documenting) by using
"str" for string variables, "int" for integers, etc.
But I think in VBScript, declaration of a variable is optional?
That does not make it right to do so. Always use "Option Explicit" at the
beginning of your code blocks. This will force you to declare your variables
and prevent embarassing and time-consuming mistakes.
HTH,
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"