473,544 Members | 1,946 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

VB.NET for-next loop syntax - simple question

Hi All,

Quick one: several times in vb.net code I have got off the net there are
lines such as:

For i As Integer = 0 To 10

which, on compiling with VS2002, produce the following error:

error BC30451: Name 'i' is not declared.

One way to fix this issue is to separate the declaration into a new line:

Dim i As Integer
For i As Integer = 0 To 10

But the fact that I keep seeing this in other people's code is making me
wonder what's going on...

Any answers out there?

Cheers,

JON
Nov 21 '05 #1
8 13967

Jon Maz wrote:
Hi All,

Quick one: several times in vb.net code I have got off the net there are lines such as:

For i As Integer = 0 To 10

which, on compiling with VS2002, produce the following error:

error BC30451: Name 'i' is not declared.

One way to fix this issue is to separate the declaration into a new line:
Dim i As Integer
For i As Integer = 0 To 10

But the fact that I keep seeing this in other people's code is making me wonder what's going on...

Any answers out there?


The ability to declare loop variables in the loop statement was one of
the (very few) *language* changes in VB.Net 2003 from 2002. The only
other was the introduction of the bit shift operators << and >>.

VB.Net 2005 (as and when it emerges) will have considerably more, be
warned.

If you are writing for people who still have VB.Net 2002, you must take
care to avoid this construct and those operators.

--
Larry Lard
Replies to group please

Nov 21 '05 #2
"Jon Maz" <jo****@surfeuN OSPAM.de> wrote in news:eqCxPG3EFH A.3512
@TK2MSFTNGP10.p hx.gbl:
For i As Integer = 0 To 10

But the fact that I keep seeing this in other people's code is making me
wonder what's going on...

Any answers out there?


Might be a new syntax extension in VB 2..5.
--
Chad Z. Hower (a.k.a. Kudzu) - http://www.hower.org/Kudzu/
"Programmin g is an art form that fights back"

Develop ASP.NET applications easier and in less time:
http://www.atozed.com/IntraWeb/
Nov 21 '05 #3
You are using Visual Studio 2002. Only in 2003 and beyond, the more compact
style of declaring for-loop (and for-each) variables in the loop header is
supported in VB.NET.

David Anton
Tangible Software Solutions Inc.
Home of the Instant C# and Instant VB .NET language converters
www.tangiblesoftwaresolutions.com

"Jon Maz" wrote:
Hi All,

Quick one: several times in vb.net code I have got off the net there are
lines such as:

For i As Integer = 0 To 10

which, on compiling with VS2002, produce the following error:

error BC30451: Name 'i' is not declared.

One way to fix this issue is to separate the declaration into a new line:

Dim i As Integer
For i As Integer = 0 To 10

But the fact that I keep seeing this in other people's code is making me
wonder what's going on...

Any answers out there?

Cheers,

JON

Nov 21 '05 #4
Larry,

Don't forget the FolderBrowserDi alog which now with SP1 seems without bugs.

The wrote it nowhere however beside the more stability, the better
conversion from VB6, and the smaller deployment, one of the major
improvements for me.

Just my thought,

Cor
Nov 21 '05 #5
Cor,
FolderBrowserDi alog was a framework change not a VB.NET Language change.

Remember Larry specifically stated " *language* changes "
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:uI******** ******@TK2MSFTN GP12.phx.gbl...
Larry,

Don't forget the FolderBrowserDi alog which now with SP1 seems without
bugs.

The wrote it nowhere however beside the more stability, the better
conversion from VB6, and the smaller deployment, one of the major
improvements for me.

Just my thought,

Cor

Nov 21 '05 #6
Mmm, thought it must be something like that...

Presumably I could use a command-line compile with v1.1 to get round this?

Thanks,

JON
Nov 21 '05 #7
Cor,

"Cor Ligthert" <no************ @planet.nl> schrieb:
Don't forget the FolderBrowserDi alog which now with SP1 seems without
bugs.


.... that's not a language change :-).

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #8
Herfried and Jay,

You both are right

LOL.

Cor
Nov 21 '05 #9

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

Similar topics

2
9401
by: Xerxes | last post by:
Hi, is there any script to authenticate an email address entered in a form field? I used the php mail() function, using the following (where my email field on the form is called "email"): $email = explode('@',$email); $mailhost = $email; $mailhost=$mailhost.".";
4
6412
by: Craig Bailey | last post by:
Anyone recommend a good script editor for Mac OS X? Just finished a 4-day PHP class in front of a Windows machine, and liked the editor we used. Don't recall the name, but it gave line numbers as well as some color coding, etc. Having trouble finding the same in an editor that'll run on OS X. -- Floydian Slip(tm) - "Broadcasting from...
0
2873
by: Verizon | last post by:
Has anybody ever heard of support for the book: "Secure PHP Development" by: Mohammed J. Kabir I'm trying to run one of his PHP solutions called "Web Forms Manager" I haven't been able to get it up and running. Thanks in advance!
0
1987
by: panic | last post by:
If you are not familiar with the palm DB apps I am refering to, they are applications that allow you to graphically create a db by adding fields(columns) and then creats a form so you can enter the info, and also you can display it in row form. So I am looking for a program that would be a type of online record keeper, where you can via the...
0
3558
by: Robert Freund | last post by:
I've been looking for a good and free code beautifier that runs on linux. About the only ones I found where Trita (www.trita.com), which costs money and only runs on windows. The other one was Beautify PHP (www.bierkandt.org/beautify) which does not offer all the features I'd like to have. I'm also more interested in something that is not...
33
9822
by: Frank | last post by:
What is the best IDE for developing PHP applications? What do you use and why? Thanks.
0
2005
by: Mr.Bogi | last post by:
Is anyone aware of an open source report generation library for php/mysql? Basically a freeware/opensource alternative to Crystal Reports. thanks
0
2183
by: Alex | last post by:
Bottom line: would like to get a weblog and bulletin board going. Would like to use phpBB2 and movabletype. I have movabletype working using mysql. Apache and php were on my linux red hat 7.2 out of the box it seems. hello.php worked with the original setup. Somewhere along the time of installing MySQL database & DBD::mysql and a...
3
5851
by: MT | last post by:
Hello Everyone: I am running XP Pro with IIS 5.1. Which is the best PHP version to install: CGI, CLI or ISAPI?? The installation manual lists all three but does not say which is most stable, fastest, other advantages/disadvantage.
5
2211
by: ChronicFatigue | last post by:
Hello My current host has register_globals switched on in their php.ini file. Would it be prudent for me to design code which works when register_globals is switched off in case I switch hosts in the future? If I dont is it normally straightforward to edit the code so that a script can be run with register_globals off in the future? ...
0
7420
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...
1
7368
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...
0
7704
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...
0
4911
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3407
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3404
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1837
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
1
983
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
657
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...

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.