Read sequential file using VB

  • Thread starter Thread starter leesa
  • Start date Start date
L

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!
 
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
 
leesa said:
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
 
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
 
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.
 
hi Cor and Homer,

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