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

Syntax not accepted on my version of VS why ?.


Hi All,

The newbie strikes back, ;)

I have downloaded several examples that contains that syntax :

For i as integer = 0 to treeview.nodes.count - 1

Why my Vs 2002 (7.0) will NOT compile as per: "Name i is not declared"?

Thanks to light me up on that one.

Cheers!

Marc R.
Jan 26 '06 #1
6 944
Marc,
| For i as integer = 0 to treeview.nodes.count - 1
| Why my Vs 2002 (7.0) will NOT compile as per: "Name i is not declared"?

Simple! the syntax was introduced with VS 2003 (7.1) .NET 1.1.

--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Marc R." <No****@NewgroupsONLY.com> wrote in message
news:ul*************@tk2msftngp13.phx.gbl...
|
| Hi All,
|
| The newbie strikes back, ;)
|
|
|
| I have downloaded several examples that contains that syntax :
|
|
|
| For i as integer = 0 to treeview.nodes.count - 1
|
|
|
| Why my Vs 2002 (7.0) will NOT compile as per: "Name i is not declared"?
|
|
|
| Thanks to light me up on that one.
|
|
|
| Cheers!
|
|
|
| Marc R.
|
|
Jan 26 '06 #2
Marc,

The syntax "For i as integer" part was not yet in the version 2002.

It has in 2002 to be
\\\
dim i as integer
For i = 0 to etc.
///

I hope this helps,

Cor
Jan 26 '06 #3

Marc R. wrote:
Hi All,

The newbie strikes back, ;)

I have downloaded several examples that contains that syntax :

For i as integer = 0 to treeview.nodes.count - 1

Why my Vs 2002 (7.0) will NOT compile as per: "Name i is not declared"?


The ability to declare loop variables 'in line' in this way was one of
only two substantive changes to the VB *language* between 2002 (7.0)
and 2003 (7.1):
What's New in Visual Basic .NET 2003
Visual Basic .NET 2003 has added functionality that simplifies bit
manipulation and loop variable declaration.

Bit Shift Operators
Visual Basic .NET now supports arithmetic left and right shift
operations on integral data types (Byte, Short, Integer, and Long).
Arithmetic shifts are not circular, which means the bits shifted off
one end of the result are not reintroduced at the other end. The
corresponding assignment operators are provided as well.

Loop Variable Declaration
Visual Basic .NET now allows you to declare a loop variable as part of
a For or For Each loop. You can include an As clause for the variable
in the For or For Each statement, provided no variable of that name has
been declared outside the loop. The scope of a loop variable declared
in this manner is the loop itself.


If you regularly have to use both versions, you may want to 'avoid
learning' the new loop variable syntax (the bit shift operators are
much less commonly encountered). The only accompanying *Framework*
change that catches me out is the addition of DataReader.HasRows.
--
Larry Lard
Replies to group please

Jan 26 '06 #4
"Marc R." <No****@NewgroupsONLY.com> schrieb:
I have downloaded several examples that contains that syntax :

For i as integer = 0 to treeview.nodes.count - 1

Why my Vs 2002 (7.0) will NOT compile as per: "Name i is not declared"?


The inline variable declaration is only supported in VS.NET 2003 (VB 7.1)
and VS 2005 (VB 8.0). Instead you need a separate declaration:

\\\
Dim i As Integer
For i = 0 To ...
...
Next i
///

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

Jan 26 '06 #5
is there an easy way to upgrade to 7.1 ?

"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:OD**************@TK2MSFTNGP11.phx.gbl...
"Marc R." <No****@NewgroupsONLY.com> schrieb:
I have downloaded several examples that contains that syntax :

For i as integer = 0 to treeview.nodes.count - 1

Why my Vs 2002 (7.0) will NOT compile as per: "Name i is not declared"?


The inline variable declaration is only supported in VS.NET 2003 (VB 7.1)
and VS 2005 (VB 8.0). Instead you need a separate declaration:

\\\
Dim i As Integer
For i = 0 To ...
...
Next i
///

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

Jan 27 '06 #6
"Marc R." <No****@NewgroupsONLY.com> schrieb
is there an easy way to upgrade to 7.1 ?


It was in 2003, when it came out ($20). You're a little late. Now version
2005 is out.
Armin

Jan 27 '06 #7

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

Similar topics

699
by: mike420 | last post by:
I think everyone who used Python will agree that its syntax is the best thing going for it. It is very readable and easy for everyone to learn. But, Python does not a have very good macro...
24
by: Steven Bethard | last post by:
I think one of the biggest reasons we're having such problems coming to any agreement on decorator syntax is that each proposal makes a number of syntax decisions, not just one. For decorators, I...
99
by: Paul McGuire | last post by:
There are a number of messages on the python-dev mail list that indicate that Guido is looking for some concensus to come from this list as to what *one* alternative syntax for decorators we would...
15
by: chirs | last post by:
I am trying to understand a piece of code. In a javascrpit file, there is a function: function ItemStyle(){ var names=; addProps(this,arguments,names,true); }; In the html file, it calls...
0
by: Arnold | last post by:
Hi, I'm using visual studio .NET 2003 enterprise and MySQL 5.0. I've created a database project in wich I like to create scripts for stored procedures and queries. I've created a connection...
7
by: Mark P | last post by:
Is this legal and sensible? class Outer { friend struct Inner { ... }; ...
4
by: Jeremy Yallop | last post by:
Looking over some code I came across a line like this if isalnum((unsigned char)c) { which was accepted by the compiler without complaint. Should the compiler have issued a diagnostic in this...
18
by: robert | last post by:
Using global variables in Python often raises chaos. Other languages use a clear prefix for globals. * you forget to declare a global * or you declare a global too much or in conflict * you...
2
by: Karthik Gurusamy | last post by:
I see python doesn't have ++ or -- operators unlike say, C. I read some reasonings talking about immutable scalars and using ++/-- doesn't make much sense in python (not sure if ++i is that...
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
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
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
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
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...
0
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...

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.