473,770 Members | 2,082 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Name Redefined

Should be a simple question...not sure why this ISN'T having a problem:

For x = 1 to 5
Dim y
Next

Shouldn't that fire a "Name Redefined" error the way this does:

For x = 1 to 5
Dim y
Next

Dim y
Jul 22 '05 #1
7 8699
The parser is pretty stupid. In the second case, it reads through the code
(without executing the loop) and sees two identical Dim statements. It has
nothing to do with how many times the statement is actually executed; only
with how many times it appears.

--
This is my signature. It is a general reminder.
Please post DDL, sample data and desired results.
See http://www.aspfaq.com/5006 for info.

"James" <le********@ver izon.net> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Should be a simple question...not sure why this ISN'T having a problem:

For x = 1 to 5
Dim y
Next

Shouldn't that fire a "Name Redefined" error the way this does:

For x = 1 to 5
Dim y
Next

Dim y

Jul 22 '05 #2
Makes sense...just wanted to make sure I wasn't missing anything. Thanks.

"Aaron [SQL Server MVP]" <te*****@dnartr eb.noraa> wrote in message
news:%2******** *******@TK2MSFT NGP15.phx.gbl.. .
The parser is pretty stupid. In the second case, it reads through the code (without executing the loop) and sees two identical Dim statements. It has nothing to do with how many times the statement is actually executed; only
with how many times it appears.

--
This is my signature. It is a general reminder.
Please post DDL, sample data and desired results.
See http://www.aspfaq.com/5006 for info.

"James" <le********@ver izon.net> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Should be a simple question...not sure why this ISN'T having a problem:

For x = 1 to 5
Dim y
Next

Shouldn't that fire a "Name Redefined" error the way this does:

For x = 1 to 5
Dim y
Next

Dim y


Jul 22 '05 #3
Now that you have your answer, may I ask if you are really planning on
dimming something in a loop like this? Or were you just playing around
trying to get an error?

Ray at work

"James" <le********@ver izon.net> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Should be a simple question...not sure why this ISN'T having a problem:

For x = 1 to 5
Dim y
Next

Shouldn't that fire a "Name Redefined" error the way this does:

For x = 1 to 5
Dim y
Next

Dim y

Jul 22 '05 #4
LOL, no...I don't intend to design something like this. Long story short,
I have an ENORMOUS page built by someone else in our company that's long
since departed. From a bare glance at the page, I knew where I needed to
put my add on, but I wasn't sure if I was inside any kind of a loop. The
code is horribly indented/commented. Curiousity sparked my example. I
ended up having to document/format the page anyway. I wasn't intending to
proceed without knowing exactly what was going on anyway. Just curiousity
=).

"Ray Costanzo [MVP]" <my first name at lane 34 dot commercial> wrote in
message news:Oa******** *****@TK2MSFTNG P12.phx.gbl...
Now that you have your answer, may I ask if you are really planning on
dimming something in a loop like this? Or were you just playing around
trying to get an error?

Ray at work

"James" <le********@ver izon.net> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Should be a simple question...not sure why this ISN'T having a problem:

For x = 1 to 5
Dim y
Next

Shouldn't that fire a "Name Redefined" error the way this does:

For x = 1 to 5
Dim y
Next

Dim y


Jul 22 '05 #5
On Tue, 12 Apr 2005 13:06:24 -0400, "Ray Costanzo [MVP]" <my first name
at lane 34 dot commercial> wrote:
in <Oa************ *@TK2MSFTNGP12. phx.gbl>
Now that you have your answer, may I ask if you are really planning on
dimming something in a loop like this? Or were you just playing around
trying to get an error?

Ray at work


It makes no matter where your Dims appear as long as they precede any
reference to the variable. I put all my Dims right where the variable
is used the first time which makes for more readable code IMHO.
---
Stefan Berglund
Jul 22 '05 #6
IIRC it doesn't matter where you put your dims as long as they are in the
same scope as the variable reference. Try this.

<%@ Language=VBScri pt %>
<%

data = "here I am"

dim data

Response.Write data
%>

--
--Mark Schupp
Head of Development
Integrity eLearning
www.ielearning.com
"Stefan Berglund" <ke****@in.theg roups> wrote in message
news:le******** *************** *********@4ax.c om...
On Tue, 12 Apr 2005 13:06:24 -0400, "Ray Costanzo [MVP]" <my first name
at lane 34 dot commercial> wrote:
in <Oa************ *@TK2MSFTNGP12. phx.gbl>
Now that you have your answer, may I ask if you are really planning on
dimming something in a loop like this? Or were you just playing around
trying to get an error?

Ray at work


It makes no matter where your Dims appear as long as they precede any
reference to the variable. I put all my Dims right where the variable
is used the first time which makes for more readable code IMHO.
---
Stefan Berglund

Jul 22 '05 #7
On Wed, 13 Apr 2005 09:33:22 -0700, "Mark Schupp" <no******@email .net>
wrote:
in <uj************ **@TK2MSFTNGP14 .phx.gbl>
IIRC it doesn't matter where you put your dims as long as they are in the
same scope as the variable reference. Try this.

<%@ Language=VBScri pt %>
<%

data = "here I am"

dim data

Response.Wri te data
%>


Interesting. VBScript is more forgiving than VB6.
---
Stefan Berglund
Jul 22 '05 #8

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

Similar topics

1
12181
by: Marc Schellens | last post by:
Including Python.h I got the following warining warning: "_POSIX_C_SOURCE" redefined in Python.h: #define _POSIX_C_SOURCE 200112L in features.h (included from string):
1
3996
by: saksenaabhishek | last post by:
Hi Guys, I have some problem in compiling the following code, specially with MSVC++.Net2003 (Code works fine with GCC compiler) ========================================= template< typename PROTOCOL> class port:public smart::smart_port< typename PROTOCOL::transport::output::type, typename PROTOCOL::transport::input::type > { private:
0
5044
by: Myron Turner | last post by:
I'm using a child handler which I've used elsewhere on various systems, but currently I am getting this message: POSIX::WNOHANG redefined my handler is as follows: sub childhandler { while((my $retv = waitpid( -1, &POSIX::WNOHANG() ))>0) {
4
1501
by: deanfamily | last post by:
Here's the problem: I have a function that references another one in this manner: class circleType: public pointType so, pointType is redefined by circleType, thereby giving circleType access to all the functions in pointType if need-be. Here is the function I am using in pointType: void pointType::setCoords(double xCoord, double yCoord) { pointX = xCoord;
16
3602
by: Vadim Biktashev | last post by:
Hello all I would like to give a certain name to a certain global variable. Unfortunately, this name is already used in math.h for a mathematical function. Worse, I do need to use maths library and therefore have to include math.h. Thus my compiler reports conflicting declarations of the same name. Does anyone know any reasonably elegant way to resolve this conflict? I understand that I can give up and choose another name, but somehow not...
5
1866
by: dragon | last post by:
error! 33 E:\program\wukexin\file\file.h `bool My_lib::Cfileinfo::initialize(const char*)' is private 19 E:\program\wukexin\dir\dir.cpp within this context //////////////////////////////////// #ifndef fileH #define fileH //// #include "windows.h" namespace My_lib{
1
2836
by: irfanhab | last post by:
Hey guys! I am having some serious problems integrating Python and C, and it's strange. Putting it simple, Just as I include Python.h in my C programe (without any further python interfacing code), and compile my C code with the options -I /usr/include/python2.4 -lpython2.4 too gcc, I get the following "warning" ===== In file included from /usr/include/python2.4/Python.h:8,
1
2341
by: colin | last post by:
Hi, I have this code wich fills in data fields from a file, recursivley down through any structures/classes the difficulty is when I come acros a field wich is a structure, wich can not be read as a binary blit. I need to be able to pass this as a reference to a function to carry on the recursion through each field... I have tried to use TypeReferences but I get this error and I cant find anything much about it.
2
4853
by: developer.new | last post by:
Hi I have a question regarding this concept I learned about recently: Name Hiding. Here's what I've come across: There is a base class with two functions with the same name but different signature. A class inherits publicly from this base class and redefines one of the two functions in the derived class. In that case, a derived class object cannot access the other base class function that it hasn't redefined. I'm posting a code snippet...
0
9595
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9432
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10232
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10008
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9873
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7420
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5454
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3974
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2822
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.