List Info

Thread: Re: reading an input file VB6 - SAMPLE CODE (VS 2005 / VB8)




Re: reading an input file VB6 - SAMPLE CODE (VS 2005 / VB8)
country flaguser name
United States
2007-10-21 16:55:17

These samples are from Visual Studio 2005 snippet library... it's the
.NET, so don't know if they'll help you, but they might...

' read a file
Dim fileContents As String
fileContents = My.Computer.FileSystem.ReadAllText(";C:Test.txt")

' write a file
My.Computer.FileSystem.WriteAllText("C:Test.txt", "Text", True)

' read a delimitted text file (delimeter could be CRLF too!!)
Dim filename As String = "C:Test.txt";
Dim fields As String()
Dim delimiter As String = ","
Using parser As New TextFieldParser(filename)
parser.SetDelimiters(delimiter)
While Not parser.EndOfData
' Read in the fields for the current line
fields = parser.ReadFields()
' Add code here to use data in fields variable.

End While
End Using

--- In VisualBasic_Official%40yahoogroups.com">VisualBasic_Officialyahoogroups.com, Mike <ckt_des...> wrote:
&gt;
> Hi all,
>; I am new to this group and trying to brush back up on my
programming skills. I haven't written a program since VB3 but now have
to get back into it with some changes to some of my old programs and
making some new. I presently have VB6.
>;
> This is probably a real simple question for most of you, but I am
totally stumped of how to proceed. I have a text file that I need to
read with lines of text such as:
> a123b900
> a1223b122
> a6b554
&gt; etc.
>; I need to use the two sets of data after the a and after the b to
do different things. The numeric data can be 1 to 5 characters in length.
> In the past, I have only used comma separated text with the
sequential file procedure, so I have been stumped on how to start on
this.
>
> Any help would be much appreciated.
> -Mike
&gt;
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> [Non-text portions of this message have been removed]
>

__._,_.___
.

__,_._,___
Re: Re: reading an input file VB6 - SAMPLE CODE (VS 2005 / VB8)
country flaguser name
United States
2007-10-22 01:40:05

Hi
This Code in VB6 if the separator is "b&quot;

Open "C:Test.txt"; for Input as #1
Dim tmp as String
Dim arr() as String
Do While not eof(1)
Input #1,tmp
arr = Split(tmp,"b&quot;)
for i = 1 to UBound(arr)
Print arr(i)
Next i
Loop

dizzycoder2000 < no_reply%40yahoogroups.com">no_replyyahoogroups.com> wrote:
These samples are from Visual Studio 2005 snippet library... it's the
.NET, so don't know if they'll help you, but they might...

' read a file
Dim fileContents As String
fileContents = My.Computer.FileSystem.ReadAllText(";C:Test.txt")

' write a file
My.Computer.FileSystem.WriteAllText("C:Test.txt&quot;, "Text", True)

' read a delimitted text file (delimeter could be CRLF too!!)
Dim filename As String = "C:Test.txt";
Dim fields As String()
Dim delimiter As String = ",&quot;
Using parser As New TextFieldParser(filename)
parser.SetDelimiters(delimiter)
While Not parser.EndOfData
' Read in the fields for the current line
fields = parser.ReadFields()
' Add code here to use data in fields variable.

End While
End Using

--- In VisualBasic_Official%40yahoogroups.com">VisualBasic_Officialyahoogroups.com, Mike <ckt_des...> wrote:
&gt;
> Hi all,
>; I am new to this group and trying to brush back up on my
programming skills. I haven't written a program since VB3 but now have
to get back into it with some changes to some of my old programs and
making some new. I presently have VB6.
>;
> This is probably a real simple question for most of you, but I am
totally stumped of how to proceed. I have a text file that I need to
read with lines of text such as:
> a123b900
> a1223b122
> a6b554
&gt; etc.
>; I need to use the two sets of data after the a and after the b to
do different things. The numeric data can be 1 to 5 characters in length.
> In the past, I have only used comma separated text with the
sequential file procedure, so I have been stumped on how to start on
this.
>
> Any help would be much appreciated.
> -Mike
&gt;
>
> __________________________________________________
> Do You Yahoo!?
> Tired of spam? Yahoo! Mail has the best spam protection around
> http://mail.yahoo.com
>
> [Non-text portions of this message have been removed]
>

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

[Non-text portions of this message have been removed]

__._,_.___
.

__,_._,___
[1-2]

about | contact  Other archives ( Real Estate discussion Medical topics )