473,403 Members | 2,071 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Very strange thing. Why does this happens?


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

Nov 19 '05 #1
2 1485
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:e0**************@TK2MSFTNGP15.phx.gbl...

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

Nov 19 '05 #2
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 news:Ps 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:e0**************@TK2MSFTNGP15.phx.gbl...

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


Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Jeff Homan | last post by:
Hello, I don't know where to begin with this as it's kind of a strange error and I can't figure it out. I've got a form that I pass several variables to a php page. One of the variables is a...
0
by: Ethel Aardvark | last post by:
I am running a 9.0.1 database on a W2K server and have come across some strange behaviour with a SQL query. I have a query which runs in a PL/SQL cursor which has several PL/SQL variables used to...
1
by: Rod | last post by:
Hi, It happens something strange with IE 6 (not with N7, Mozilla...). I want a div with a background picture. Within it, I want a picture with a text floating. With IE, the text is not always...
6
by: leonecla | last post by:
Hi everybody, I'm facing a very very strange problem with a very very simple C program... My goal should be to write to a binary file some numbers (integers), each one represented as a sequence...
6
by: No_Excuses | last post by:
All, I am interested in reading the text of a web page and parsing it. After searching on this newgroup I decided to use the following: ******************************* START OF CODE...
14
by: Lars Netzel | last post by:
A little background: I use three Datagrids that are in a child parent relation. I Use Negative Autoincrement on the the DataTables and that's workning nice. My problem is when I Update these...
1
by: Mark Lauser | last post by:
I am working with a vb.net web application (.net v1.1). Currently all of the buttons work on all of the pages. However, we just got a new web server and have found that some of the buttons don't...
112
by: Prisoner at War | last post by:
Friends, your opinions and advice, please: I have a very simple JavaScript image-swap which works on my end but when uploaded to my host at http://buildit.sitesell.com/sunnyside.html does not...
1
by: Rafe | last post by:
Hi, I'm getting this error: # File "C:\Python25\Lib\site-packages\win32com\client\dynamic.py", line 491, in __getattr__ # raise pythoncom.com_error, details # COM Error: Unspecified...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.