"using statments"

  • Thread starter Thread starter Shooter4Life8
  • Start date Start date
S

Shooter4Life8

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:\testfile.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.MalformedLineException
MsgBox("Line " & ex.Message & _
"is not valid and will be skipped.")
End Try
End While
End Using

Thanks!
 
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
 
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.
 
Unfortunatly "Using" is a VB 2005 feature only.

For VB.Net 1.0, you're stuck using the try/finally syntax.
 
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.


I see. I guess i'll have to find a way around it then.
 
Back
Top