Home All Groups Group Topic Archive Search About

Read sequential file using VB

Author
5 Apr 2006 3:39 AM
leesa
I have a number field in a sequential file. Im going to read this file,
sum up this number and display the grand total in my application using
VB. Do anyone know how to do that??


Thanks in advance!

Author
5 Apr 2006 4:39 AM
Cor Ligthert [MVP]
Leesa,

>I have a number field in a sequential file. Im going to read this file,
> sum up this number and display the grand total in my application using
> VB. Do anyone know how to do that??
>
This is so basic programming.
Try to get a book about programming it does not matter how old it is.
Than get VBExpress

What you have to do is open a windowsform project
Drag from the toolbox a label on the form that is created
Click on that form
Search for MSDN.microsoft.com for "streamreader"
Follow one of the samples on that page

I hope this helps,

Cor
Author
5 Apr 2006 6:02 AM
Homer J Simpson
"leesa" <angk***@gmail.com> wrote in message
news:1144208387.621836.56240@v46g2000cwv.googlegroups.com...
>I have a number field in a sequential file. Im going to read this file,
> sum up this number and display the grand total in my application using
> VB. Do anyone know how to do that??

Dim fileReader As System.IO.StreamReader
fileReader = My.Computer.FileSystem.OpenTextFileReader ("C:\File.txt")
Dim myData As String
Do
    myData = fileReader.ReadLine()
Loop While Not fileReader.EndOfStream
Author
5 Apr 2006 6:18 AM
Cor Ligthert [MVP]
Homer,

If you write it so exact, would you not count in the routine.

Something as

> Dim fileReader As System.IO.StreamReader
> fileReader = My.Computer.FileSystem.OpenTextFileReader ("C:\File.txt")
> Dim myData As String
   label1.text = ""
> Do
>    myData = fileReader.ReadLine()
      Label1.text = CDbl(Label1.Text) +  CDbl(myData.Substring(0,6))
       'to count the first 6 characters

> Loop While Not fileReader.EndOfStream
>
:-))

Cor
Author
5 Apr 2006 6:31 AM
Homer J Simpson
"Cor Ligthert [MVP]" <notmyfirstn***@planet.nl> wrote in message
news:uKw8AiHWGHA.128@TK2MSFTNGP05.phx.gbl...


> If you write it so exact, would you not count in the routine.
>
> Something as
....

Sure. I have a bunch of code in there for my purpose but the OP needs to add
his summing code.
Author
5 Apr 2006 6:53 AM
anzhi
hi Cor and Homer,

Thanks for ur explanation and code example ya. Very grateful to get
feedback from u guys. thanks!