|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
"using statments"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 ---------------------- Show quoteHide quote | GroupNumber | The code I will be modifying to read is as follows. Is there a better---------------------- | 6152 | ---------------------- | 4253 | ---------------------- | 1151 | ---------------------- | ABC1883 | ---------------------- | ABC2135 | ---------------------- | 785HBLA | ---------------------- | 785HBLA | ---------------------- 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! Shooter4Li***@gmail.com wrote:
> for some reason when i try to use a "using" statment i get an error Be aware that the Using keyword is only valid in VB.Net for .Net 2.0.> saying. > > "Name 'Using' is not declared." > It is not available in .Net 1.1 <Shooter4Li***@gmail.com> schrieb:
> for some reason when i try to use a "using" statment i get an error The 'Using' statement (and 'TextFieldParser') is only supported in VB 2005 > saying. > > "Name 'Using' is not declared." 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/> I see. I guess i'll have to find a way around it then.
Herfried K. Wagner [MVP] wrote: Show quoteHide quote > <Shooter4Li***@gmail.com> schrieb: > > 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/> 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. <Shooter4Li***@gmail.com> wrote in message Show quoteHide quote news:1160516648.122096.90900@i3g2000cwc.googlegroups.com... >I see. I guess i'll have to find a way around it then. > > > Herfried K. Wagner [MVP] wrote: >> <Shooter4Li***@gmail.com> schrieb: >> > 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/> > Unfortunatly "Using" is a VB 2005 feature only.
For VB.Net 1.0, you're stuck using the try/finally syntax. -- Show quoteHide quoteChris Mullins, MCSD.NET, MCPD:Enterprise http://www.coversant.net/blogs/cmullins <Shooter4Li***@gmail.com> wrote in message news:1160514462.769934.307450@i3g2000cwc.googlegroups.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:\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! > |
|||||||||||||||||||||||