473,406 Members | 2,894 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,406 software developers and data experts.

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 13962

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****@surfeuNOSPAM.de> wrote in news:eqCxPG3EFHA.3512
@TK2MSFTNGP10.phx.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/
"Programming 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 FolderBrowserDialog 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,
FolderBrowserDialog 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**************@TK2MSFTNGP12.phx.gbl...
Larry,

Don't forget the FolderBrowserDialog 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 FolderBrowserDialog 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
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"): ...
4
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...
0
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...
0
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...
0
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...
33
by: Frank | last post by:
What is the best IDE for developing PHP applications? What do you use and why? Thanks.
0
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
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...
3
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...
5
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: 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
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,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.