Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Microsoft VBScript runtime (0x800A01F5): Illegal assignment: variable name

Reply
Thread Tools

Microsoft VBScript runtime (0x800A01F5): Illegal assignment: variable name

 
 
Matt
Guest
Posts: n/a
 
      01-11-2004
<% hour = Request("controlname") %> will yield the following error:

Microsoft VBScript runtime (0x800A01F5)
Illegal assignment: 'hour'

However, if I declare hour, then it is fine.
<%
Dim hour
hour = Request("controlname")
%>

But I think in VBScript, declaration of a variable is optional? That means
we can use the variable without writing "Dim hour" ??

Please advise! thanks!



 
Reply With Quote
 
 
 
 
Gervin
Guest
Posts: n/a
 
      01-11-2004
If u use a variable name that is NOT a function name as well, then u don't
have to declare it.
Hour( ) is a built-in function.

"Matt" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> <% hour = Request("controlname") %> will yield the following error:
>
> Microsoft VBScript runtime (0x800A01F5)
> Illegal assignment: 'hour'
>
> However, if I declare hour, then it is fine.
> <%
> Dim hour
> hour = Request("controlname")
> %>
>
> But I think in VBScript, declaration of a variable is optional? That means
> we can use the variable without writing "Dim hour" ??
>
> Please advise! thanks!
>
>
>



 
Reply With Quote
 
 
 
 
Bob Barrows
Guest
Posts: n/a
 
      01-11-2004
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"


 
Reply With Quote
 
Brynn
Guest
Posts: n/a
 
      01-11-2004
Yeah, just use theHour or somthing to that effect ... or when I am
lazy, I will pout the letter z in front of everything .. LOL

zHour


On Sat, 10 Jan 2004 23:23:05 -0800, "Matt" <(E-Mail Removed)>
wrote:

><% hour = Request("controlname") %> will yield the following error:
>
>Microsoft VBScript runtime (0x800A01F5)
>Illegal assignment: 'hour'
>
>However, if I declare hour, then it is fine.
><%
> Dim hour
> hour = Request("controlname")
>%>
>
>But I think in VBScript, declaration of a variable is optional? That means
>we can use the variable without writing "Dim hour" ??
>
>Please advise! thanks!
>
>
>


 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
adding a variable name to a hash to name is part of the variable name Bobby Chamness Perl 2 04-22-2007 09:54 PM
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd loyola MCSE 4 11-15-2006 02:40 AM
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd loyola Microsoft Certification 3 11-14-2006 05:18 PM
microsoft.public.certification, microsoft.public.cert.exam.mcsa, microsoft.public.cert.exam.mcad, microsoft.public.cert.exam.mcse, microsoft.public.cert.exam.mcsd realexxams@yahoo.com Microsoft Certification 0 05-10-2006 02:35 PM
microsoft.public.dotnet.faqs,microsoft.public.dotnet.framework,microsoft.public.dotnet.framework.windowsforms,microsoft.public.dotnet.general,microsoft.public.dotnet.languages.vb Charles A. Lackman ASP .Net 1 12-08-2004 07:08 PM



Advertisments