473,386 Members | 1,757 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,386 software developers and data experts.

Using For Each in VB.NET

When I try to declare my element in (as opposed to before)
my "For Each" statement I get a syntax error. When I try
to do the same thing in C# I have no problem.

This does not work...
For Each node As XmlNode In nodeList
Me.ListBox1.Items.Add(node.InnerText)
Next

This does...
Dim node As XmlNode
For Each node In nodeList
Me.ListBox1.Items.Add(node.InnerText)
Next

And this works in C#
foreach (XmlNode node in nodeList)
this.listBox1.Items.Add(node.InnerText);

According to Help | About in Visual Studio .NET, I am
using MS Development Environment 2002, version 7.0.9466
and MS .NET Framework 1.0, version 1.0.3705 (I have
installed Service Pack 2).

Nov 20 '05 #1
2 7558

"John" <an*******@discussions.microsoft.com> wrote in message
news:0d****************************@phx.gbl...
When I try to declare my element in (as opposed to before)
my "For Each" statement I get a syntax error. When I try
to do the same thing in C# I have no problem.

This does not work...
For Each node As XmlNode In nodeList
Me.ListBox1.Items.Add(node.InnerText)
Next


This syntax was added to VB in the DotNet Framework 1.1. So you would need
to use Visual Studio .NET 2003.

David
Nov 20 '05 #2
* "John" <an*******@discussions.microsoft.com> scripsit:
When I try to declare my element in (as opposed to before)
my "For Each" statement I get a syntax error. When I try
to do the same thing in C# I have no problem.

This does not work...
For Each node As XmlNode In nodeList
Me.ListBox1.Items.Add(node.InnerText)
Next

This does...
Dim node As XmlNode
For Each node In nodeList
Me.ListBox1.Items.Add(node.InnerText)
Next

And this works in C#
foreach (XmlNode node in nodeList)
this.listBox1.Items.Add(node.InnerText);

According to Help | About in Visual Studio .NET, I am
using MS Development Environment 2002, version 7.0.9466
and MS .NET Framework 1.0, version 1.0.3705 (I have
installed Service Pack 2).


You will have to upgrade to VS.NET 2003 in order to use this language
feature in VB.NET too.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3

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

Similar topics

2
by: Ralph Snart | last post by:
Is there a way to alternate table row colors without using the position() mod 2 trick? I'm in a series of nested xsl:for-each elements, about 3 deep, and I want to alternate the table row color...
10
by: Gregory A Greenman | last post by:
I'm trying to write a program in vb.net to automate filling out a series of forms on a website. There are three forms I need to fill out in sequence. The first one is urlencoded. My program is...
13
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be...
3
by: Ben | last post by:
Hi all - I am having a bit of trouble and thought maybe someone in this group could shed some light. Here's the skinny... I am creating an automated process to import a bunch of text files...
17
by: Danny J. Lesandrini | last post by:
The following code works with a standard MDB to navigate to a particluar record (with a DAO recordset, of course) but it's giving me problems in an ADP I'm working on. Dim rs As ADODB.Recordset...
1
by: barma16 | last post by:
I've hit a bit of a brick wall here, and could use some advice. I have an Access application whose output is a four-tab Excel spreadsheet where three of the four tabs are the result of database...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
4
by: Kathy | last post by:
What is the standard technique for handling the fields in the following scenario on a continuous form? Multiple Divisions. Each Division has multiple Buildings. Each Building has a Supervisor. ...
1
by: fred_mumble | last post by:
I have been testing various techniques to run "script" code which will be stored in a SQL database and executed dynamically at runtime. The scripts are essentially business rules that result in a...
9
by: George McCullen | last post by:
I have an Outlook 2003 using Exchange Server 2003 Public Contacts Folder containing 20,000 Contacts. I am writing a VB .Net 2003 program that loops through all the contacts in a "for each oCt in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...

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.