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

"using statments"

for some reason when i try to use a "using" statment i get an error
saying.

"Name 'Using' is not declared."

does that mean that i need to inheirit or import from a class? Im
trying to use it to read from a file. The file format is as follows.
The information I want are the group numbers

----------------------
| GroupNumber |
----------------------
| 6152 |
----------------------
| 4253 |
----------------------
| 1151 |
----------------------
| ABC1883 |
----------------------
| ABC2135 |
----------------------
| 785HBLA |
----------------------
| 785HBLA |
----------------------

The code I will be modifying to read is as follows. Is there a better
way to go about this? Or should I just work with this? (this code is
from msdn. and is used for commadilimited files)
Visual Basic Copy CodeUsing MyReader As New _
Microsoft.VisualBasic.FileIO.TextFieldParser("C:\t estfile.txt")
MyReader.TextFieldType = FileIO.FieldType.Delimited
MyReader.SetDelimiters(",")
Dim currentRow As String()
While Not MyReader.EndOfData
Try
currentRow = MyReader.ReadFields()
Dim currentField As String
For Each currentField In currentRow
MsgBox(currentField)
Next
Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineExceptio n
MsgBox("Line " & ex.Message & _
"is not valid and will be skipped.")
End Try
End While
End Using

Thanks!

Oct 10 '06 #1
5 1279
Sh***********@gmail.com wrote:
for some reason when i try to use a "using" statment i get an error
saying.

"Name 'Using' is not declared."
Be aware that the Using keyword is only valid in VB.Net for .Net 2.0.
It is not available in .Net 1.1

Oct 10 '06 #2
<Sh***********@gmail.comschrieb:
for some reason when i try to use a "using" statment i get an error
saying.

"Name 'Using' is not declared."
The 'Using' statement (and 'TextFieldParser') is only supported in VB 2005
and not in older versions of Visual Basic .NET.

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

Oct 10 '06 #3
Unfortunatly "Using" is a VB 2005 feature only.

For VB.Net 1.0, you're stuck using the try/finally syntax.

--
Chris Mullins, MCSD.NET, MCPD:Enterprise
http://www.coversant.net/blogs/cmullins

<Sh***********@gmail.comwrote in message
news:11**********************@i3g2000cwc.googlegro ups.com...
for some reason when i try to use a "using" statment i get an error
saying.

"Name 'Using' is not declared."

does that mean that i need to inheirit or import from a class? Im
trying to use it to read from a file. The file format is as follows.
The information I want are the group numbers

----------------------
| GroupNumber |
----------------------
| 6152 |
----------------------
| 4253 |
----------------------
| 1151 |
----------------------
| ABC1883 |
----------------------
| ABC2135 |
----------------------
| 785HBLA |
----------------------
| 785HBLA |
----------------------

The code I will be modifying to read is as follows. Is there a better
way to go about this? Or should I just work with this? (this code is
from msdn. and is used for commadilimited files)
Visual Basic Copy CodeUsing MyReader As New _
Microsoft.VisualBasic.FileIO.TextFieldParser("C:\t estfile.txt")
MyReader.TextFieldType = FileIO.FieldType.Delimited
MyReader.SetDelimiters(",")
Dim currentRow As String()
While Not MyReader.EndOfData
Try
currentRow = MyReader.ReadFields()
Dim currentField As String
For Each currentField In currentRow
MsgBox(currentField)
Next
Catch ex As Microsoft.VisualBasic.FileIO.MalformedLineExceptio n
MsgBox("Line " & ex.Message & _
"is not valid and will be skipped.")
End Try
End While
End Using

Thanks!

Oct 10 '06 #4
I see. I guess i'll have to find a way around it then.
Herfried K. Wagner [MVP] wrote:
<Sh***********@gmail.comschrieb:
for some reason when i try to use a "using" statment i get an error
saying.

"Name 'Using' is not declared."

The 'Using' statement (and 'TextFieldParser') is only supported in VB 2005
and not in older versions of Visual Basic .NET.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>
Oct 10 '06 #5
Using will automatically call the dispose method of the class you are
"using", so if you don't have access to that language element, just make
sure you call the dispose method of your instance when you are done with it.
<Sh***********@gmail.comwrote in message
news:11*********************@i3g2000cwc.googlegrou ps.com...
>I see. I guess i'll have to find a way around it then.
Herfried K. Wagner [MVP] wrote:
><Sh***********@gmail.comschrieb:
for some reason when i try to use a "using" statment i get an error
saying.

"Name 'Using' is not declared."

The 'Using' statement (and 'TextFieldParser') is only supported in VB
2005
and not in older versions of Visual Basic .NET.

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

Oct 10 '06 #6

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

Similar topics

0
by: Justin | last post by:
Hi. I decided to tidy up some of my queries, but I came across something that stumpt me: mysql> SELECT -> jobs.jobId, -> jobs.active, -> jobs.title, -> jobs.listed, -> ...
0
by: Oliver | last post by:
> I am seeing an 'Access Denied' exception when using a "Server" "Serviced Component" >> ..are...registered in the GAC ? yes. >> ..are...the parameters serializable? um - parameters? - the...
7
by: Willem van Rumpt | last post by:
Hi all, coming from an unmanaged programming background, I took my time to sort out the IDisposable and finalizer patterns. Just when I thought I had it all conceptually neatly arranged, the...
5
by: charliewest | last post by:
I've implemented the USING statement to ensure that my newly created sql connection closes when my method is finished using it. The USING statement is wrapped in try/catch error handling statement....
14
by: MuZZy | last post by:
Hi, Lately i've been (and still am) fixing some memory leaks problems in the project i just took over when i got this new job. Among the other issues i've noticed that for localy created objects...
0
by: Rave | last post by:
This is a long shot, but I thought I'd try it. I am currently using excel as an inventory tool. I currently have a hand-held scanner plugged into a laptop for reading barcodes. Using the "Find and...
21
by: comp.lang.tcl | last post by:
set php {<? print_r("Hello World"); ?>} puts $php; # PRINTS OUT <? print_r("Hello World"); ?> puts When I try this within TCL I get the following error:
15
by: arnuld | last post by:
-------- PROGRAMME ----------- /* Stroustrup, 5.6 Structures STATEMENT: this programmes *tries* to do do this in 3 parts: 1.) it creates a "struct", named "jd", of type "address". 2. it...
25
by: samjnaa | last post by:
Please check for sanity and approve for posting at python-dev. In Visual Basic there is the keyword "with" which allows an object- name to be declared as governing the following statements. For...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.