open txt file and read strings 
Author Message
 open txt file and read strings

Hi,

I am trying to write a simple console application using
vb .net 2002.

I want to open a text file which was generated using
hyperteminal and it contains lines of text with some
numerical data.

Then I need to manipulate the strings (line by line) to
extract the numerical data.

My question is:

How can I open this file? I tried the open command but the
editor tells me it is part of the windows.visualbasic
namespace.

When I put this in the reference list and put the line
IMPORTS WINDOWS.VISUALBASIC in my code it still does not
recognize the open command. Also the imports command is
not valid.

What do I do wrong? Is this the way to go or do I need
some other way to open the file to get my data?

Thanks for your help,

Robert



Fri, 07 Oct 2005 00:00:57 GMT  
 open txt file and read strings
Uses System.IO classes

Dim oFile As New System.IO.StreamReader("c:\text.txt")
      Dim s As String
      Do
         s = oFile.ReadLine()
         Console.WriteLine(s)
      Loop Until s Is Nothing
   End Sub

HTH

--
Corrado Cavalli [Microsoft .NET MVP]
UGIdotNET - http://www.ugidotnet.org



Fri, 07 Oct 2005 01:10:30 GMT  
 open txt file and read strings

Quote:
> I am trying to write a simple console application using
> vb .net 2002.

> I want to open a text file which was generated using
> hyperteminal and it contains lines of text with some
> numerical data.

> Then I need to manipulate the strings (line by line) to
> extract the numerical data.

> My question is:

> How can I open this file? I tried the open command but the
> editor tells me it is part of the windows.visualbasic
> namespace.

> When I put this in the reference list and put the line
> IMPORTS WINDOWS.VISUALBASIC in my code it still does not
> recognize the open command. Also the imports command is
> not valid.

> What do I do wrong? Is this the way to go or do I need
> some other way to open the file to get my data?

I haven't heard of WINDOWS.VISUALBASIC. There's only Microsoft.VisualBasic,
but it's already part of the list of imported names for new projects, so you
don't have to add it.

Have a look at:
ms-help://MS.VSCC/MS.MSDNVS/vbcn7/html/vbconFolderFileProcessing.htm

--
Armin



Fri, 07 Oct 2005 01:44:37 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. Read from specific string in txt file to end

2. open a txt file for the user to view and read

3. Open and .txt files for read only problem

4. Question about writing a string to a text file (file.txt)

5. Adding .TXT files to a VB program without the .TXT file

6. How to write a string to a .txt file

7. Extracting string from txt file

8. Exporting Strings to a TXT File without Quotes

9. Search string on txt file Help Need!

10. Help needed to parse a txt file/string.

11. Replace a string in a txt file

12. how to load a txt file in a string in visual basic

 

 
Powered by phpBB® Forum Software