Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Very strange thing. Why does this happens?

Reply
Thread Tools

Very strange thing. Why does this happens?

 
 
Shapper
Guest
Posts: n/a
 
      05-20-2005

Hello,

I have this code:

[1] Dim cultureList(,) As String = {{"E", "en-GB"}, {"P", "pt-PT"}}
[2] Select Case Session("culture")
[3] Case "pt-PT"
[4] ...
[5] Dim cultureList(,) As String = {{"E", "en-GB"}, {"P", "pt-PT"}}
[6] Response.Write("1")
[7] Case "en-GB"
[8] ...
[9] Dim cultureList(,) As String = {{"E", "en-GB"}, {"P", "pt-PT"}}
[10] Response.Write("2")
[11] Case Else
[12] Dim cultureList(,) As String = {{"E", "en-GB"}, {"P", "pt-PT"}}
[13] Response.Write("3")
[14] End Select

[15] ddlculture.DataSource = cultureList
[16] ddlculture.DataBind()

Something very strange is happening:
If I declare cultureList in line [1] and delete the lines [5], [9] and
[12] everything works fine. However, if I declare the string inside the
case, i.e., I keep lines [5], [9] and [12] but delete the line [1] I get
an error on line [15] saying: "Name 'cultureList' is not declared."

Why is this? Isn't this strange?

And yes the case is working. That is why I have the Response.Write
lines.

Thanks,
Miguel

 
Reply With Quote
 
 
 
 
Matt Dockerty
Guest
Posts: n/a
 
      05-20-2005
Not sure what it's like for you VB folk but in C# we have to define
variables in the scope in which they will be used - so a Dim inside the case
statement only defines a variable at that level.

"Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
news:(E-Mail Removed)...
>
> Hello,
>
> I have this code:
>
> [1] Dim cultureList(,) As String = {{"E", "en-GB"}, {"P", "pt-PT"}}
> [2] Select Case Session("culture")
> [3] Case "pt-PT"
> [4] ...
> [5] Dim cultureList(,) As String = {{"E", "en-GB"}, {"P", "pt-PT"}}
> [6] Response.Write("1")
> [7] Case "en-GB"
> [8] ...
> [9] Dim cultureList(,) As String = {{"E", "en-GB"}, {"P", "pt-PT"}}
> [10] Response.Write("2")
> [11] Case Else
> [12] Dim cultureList(,) As String = {{"E", "en-GB"}, {"P", "pt-PT"}}
> [13] Response.Write("3")
> [14] End Select
>
> [15] ddlculture.DataSource = cultureList
> [16] ddlculture.DataBind()
>
> Something very strange is happening:
> If I declare cultureList in line [1] and delete the lines [5], [9] and
> [12] everything works fine. However, if I declare the string inside the
> case, i.e., I keep lines [5], [9] and [12] but delete the line [1] I get
> an error on line [15] saying: "Name 'cultureList' is not declared."
>
> Why is this? Isn't this strange?
>
> And yes the case is working. That is why I have the Response.Write
> lines.
>
> Thanks,
> Miguel
>



 
Reply With Quote
 
 
 
 
Shapper
Guest
Posts: n/a
 
      05-20-2005
Wow,

Probably in VB is the same. Didn't know that.

I have been programming in other languages so things become a mess here.

Thanks,
Miguel

"Matt Dockerty" <Ps reply to group> wrote in message newss reply to
group:

> Not sure what it's like for you VB folk but in C# we have to define
> variables in the scope in which they will be used - so a Dim inside the case
> statement only defines a variable at that level.
>
> "Shapper" <mdmoura*NOSPAM*@gmail.*DELETE2SEND*com> wrote in message
> news:(E-Mail Removed)...
>
> >
> > Hello,
> >
> > I have this code:
> >
> > [1] Dim cultureList(,) As String = {{"E", "en-GB"}, {"P", "pt-PT"}}
> > [2] Select Case Session("culture")
> > [3] Case "pt-PT"
> > [4] ...
> > [5] Dim cultureList(,) As String = {{"E", "en-GB"}, {"P", "pt-PT"}}
> > [6] Response.Write("1")
> > [7] Case "en-GB"
> > [8] ...
> > [9] Dim cultureList(,) As String = {{"E", "en-GB"}, {"P", "pt-PT"}}
> > [10] Response.Write("2")
> > [11] Case Else
> > [12] Dim cultureList(,) As String = {{"E", "en-GB"}, {"P", "pt-PT"}}
> > [13] Response.Write("3")
> > [14] End Select
> >
> > [15] ddlculture.DataSource = cultureList
> > [16] ddlculture.DataBind()
> >
> > Something very strange is happening:
> > If I declare cultureList in line [1] and delete the lines [5], [9] and
> > [12] everything works fine. However, if I declare the string inside the
> > case, i.e., I keep lines [5], [9] and [12] but delete the line [1] I get
> > an error on line [15] saying: "Name 'cultureList' is not declared."
> >
> > Why is this? Isn't this strange?
> >
> > And yes the case is working. That is why I have the Response.Write
> > lines.
> >
> > Thanks,
> > Miguel
> >


 
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
findcontrol("PlaceHolderPrice") why why why why why why why why why why why Mr. SweatyFinger ASP .Net 2 12-02-2006 03:46 PM
very very very long integer shanx__=|;- C Programming 19 10-19-2004 03:55 PM
very very very long integer Abhishek Jha C Programming 4 10-17-2004 08:19 AM
Quick Book file access very very very slow Thomas Reed Computer Support 7 04-09-2004 08:09 PM
very Very VERY dumb Question About The new Set( ) 's Raymond Arthur St. Marie II of III Python 4 07-27-2003 12:09 AM



Advertisments