Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Dim inside Select case executes in any case?

Reply
Thread Tools

Dim inside Select case executes in any case?

 
 
Bob Barrows [MVP]
Guest
Posts: n/a
 
      04-23-2007
aa wrote:
> I discovered that "yes".


OK, I misread your question and answered "no" instead of "yes", but
supplied the correct explanation for the behavior.

> If it were "no" then wy code in my original message
> =======================
> Select case q
> Case "a"
> Dim arr(5)
> Case "b"
> Dim arr(2)
> end select
> =====================
> returns an error saying variable arr redefined.


Because both dim statements get "hoisted" to the beginning of the
procedure during compilation. Both statements. So at runtime, what gets
executed is:

Dim arr(5)
Dim arr(2) '---raises error
Select Case q
etc.

Again, there is no conditional declaration allowed in vbscript.


--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.


 
Reply With Quote
 
 
 
 
aa
Guest
Posts: n/a
 
      04-23-2007
So it looks like Dim is executed before other code on a page as if this
other code is not there. Therefore my Select case is stripped down to
Dim arr(5)
Dim arr(2)


"Dave Anderson" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> aa wrote:
> > Code like this
> > =======================
> > Select case q
> > Case "a"
> > Dim arr(5)
> > Case "b"
> > Dim arr(2)
> > end select
> > =====================
> > returns an error saying variable arr redefined.
> > Should it be like that or an I using Select incorrectly? Perhaps
> > something similar to break needs to be used?

>
> http://blogs.msdn.com/ericlippert/ar...18/159378.aspx
>
>
>
> --
> Dave Anderson
>
> Unsolicited commercial email will be read at a cost of $500 per message.

Use
> of this email address implies consent to these terms.
>
>



 
Reply With Quote
 
 
 
 
Dave Anderson
Guest
Posts: n/a
 
      04-23-2007
top.
to
bottom
from
read
not
do
conversations
sentences,
Like
top-post.
not
do
Please

aa wrote:
>> http://blogs.msdn.com/ericlippert/ar...18/159378.aspx
>>

> So it looks like Dim is executed before other code on a page as if
> this other code is not there. Therefore my Select case is stripped
> down to Dim arr(5)
> Dim arr(2)


Not "executed", exactly, but you have the right idea.


--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms.


 
Reply With Quote
 
aa
Guest
Posts: n/a
 
      04-24-2007
Dave, are you OK?
"Dave Anderson" <(E-Mail Removed)> wrote in message
news:OEI#(E-Mail Removed)...
> top.
> to
> bottom
> from
> read
> not
> do
> conversations
> sentences,
> Like
> top-post.
> not
> do
> Please
>
> aa wrote:
> >> http://blogs.msdn.com/ericlippert/ar...18/159378.aspx
> >>

> > So it looks like Dim is executed before other code on a page as if
> > this other code is not there. Therefore my Select case is stripped
> > down to Dim arr(5)
> > Dim arr(2)

>
> Not "executed", exactly, but you have the right idea.
>
>
> --
> Dave Anderson
>
> Unsolicited commercial email will be read at a cost of $500 per message.

Use
> of this email address implies consent to these terms.
>
>



 
Reply With Quote
 
aa
Guest
Posts: n/a
 
      04-24-2007
This is what I have. Thanks

> Because both dim statements get "hoisted" to the beginning of the
> procedure during compilation. Both statements. So at runtime, what gets
> executed is:
>
> Dim arr(5)
> Dim arr(2) '---raises error
> Select Case q
> etc.
>
> Again, there is no conditional declaration allowed in vbscript.



 
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
Multidimensional array, one dim fix, one dim dynamic Florian Kaufmann C++ 1 04-28-2010 01:21 PM
"case when" executes a symbol as method Francisco Laguna Ruby 5 06-17-2007 08:20 AM
501 PIX "deny any any" "allow any any" Any Anybody? Networking Student Cisco 4 11-16-2006 10:40 PM
System.arraycopy (2 dim array) and growth of 2 dim array Denis Palas Java 1 11-11-2006 09:22 AM
how to case select with case-insensitive string ? Tee ASP .Net 3 06-23-2004 07:40 PM



Advertisments