Read a text file into an array

dmdougla

Member
Joined
Apr 30, 2004
Messages
6
Here is some of my code and I am really lost .

Public Structure sPayroll
Public empNum2 As Integer
Public pDate As String
Public gross As Double
Public wHolding As Double
Public FICA As Double
Public net As Double
End Structure

I want to read data from a Payroll.txt file into this structure. How do I do this.
 
dmdougla said:
Here is some of my code and I am really lost .

Public Structure sPayroll
Public empNum2 As Integer
Public pDate As String
Public gross As Double
Public wHolding As Double
Public FICA As Double
Public net As Double
End Structure

I want to read data from a Payroll.txt file into this structure. How do I do this.

The data would have to be on one line each per item (to do it easily).

Code:
        Dim payroll As sPayroll

        Do While Reader.ReadLine = "***"
            With payroll
                .empNum2 = Reader.ReadLine
                .FICA = Reader.ReadLine
                .gross = Reader.ReadLine
                .net = Reader.ReadLine
                .pDate = Reader.ReadLine
                .wHolding = Reader.ReadLine
            End With
        Loop

This is set up for a seperater being: ***. Anything else will stop reading.

So the text file has to be formated:

Seperator
EmployeeNumber
FICA
Gross
NET
Date
witholding
Seperator
etc

You may have to create funtions to validate the data. You wouldnt want to kill your app by throwing someones name into their gross pay or ID number.

Honestly I hope this is just a project. I dont think a textfile is the safest place to hold tax information for employees. Id at least go with a database that was password protected.

In the least Id write/read to/from a text file in some sort of encrypted form like creating a function to scramble/unscramble the characters in the string.
 
dmdougla said:
Thanks you saved me a lot of time.

Try to do as much as you can, then ask as specific questions as you can.

Honestly I did this because I read the post, then realized I needed to create a setting file for my app. So I did this for my app to hold settings.
 
Back
Top