Home All Groups Group Topic Archive Search About
Author
10 Oct 2006 9:07 PM
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

----------------------
Show quoteHide quote
|    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!

Author
10 Oct 2006 9:19 PM
Chris Dunaway
Shooter4Li***@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
Author
10 Oct 2006 9:21 PM
Herfried K. Wagner [MVP]
<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/>
Author
10 Oct 2006 9:44 PM
Shooter4Life8
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/>
Author
10 Oct 2006 9:56 PM
Scott M.
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/>
>
Author
10 Oct 2006 9:41 PM
Chris Mullins
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

<Shooter4Li***@gmail.com> wrote in message
Show quoteHide quote
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!
>