Creating sequential file using Visual Basic 6.0

How to create a sequential file using Visual basic 6.0 that will load a user-defined type from the sequential file with an extra field for the pay. A command button will called findpay will use a for next loop to process the array. First you will display an input box for he number of hours worked, calculate the pay, and add to the totals.  Then you will display the labels for the next employee.  (Place the pay into the extra field in the array.  An exit button will print a report on the printer and terminate the project.  (Print the array) Hours over 40 recieve time and a half pay. accumulate the total num. hours worked, total num. hours overtime, and total amount of pay.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

LakeshaJAuthor Commented:
This question needs to be answer ASAP
Try this

dim stFilename as string
stFilename = app.path & "\Text.txt"
Open stFilename for output as #1

Print #1, "This is how to output to a text file."

Close #1


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Now, you can control the spacing in this with commands such as

Print #1, tab(10); "This will be 10 spaces from the left margin"


Print #1, spc(10); "This will be 10 spaces from the most recent text on this line"

adding a ";" after the text will keep the current printing spot on the same line


Print #1, "This line of code and the next";
Print #1, "will be on the same line in the file"

and last but not least, you can output variables the same way

Print #1, ststring

I hope this is what you wanted.
Picking up on 'User-defined' with extra field, place something like this in the decarations section of a module

Type UserDetails
    Firstname As String * 20
    Middlename As String * 20
    LastName As String * 20
    HoursWorked As Integer
    PayRate As Currency
End Type

Type UserPay
    ud As UserDetails
    Pay As Currency
End Type
Read a record from a sequential file into text boxes on a form

Sub GetRecord(InputFile As String, Recordnumber As Long)
    Dim f As Integer
    Dim ud As UserDetails
    f = FreeFile
    Open InputFile For Binary As #f
        Get #f, Recordnumber, ud
        txtFirstName.Text = ud.Firstname
        txtHoursWorked.Text = ud.HoursWorked
    Close #f
End Sub

Save the record with the extra field to another sequential file using this sort of code:

Sub SaveRecord(OutPutFile As String, Recordnumber As Long)
    Dim f As Integer
    Dim up As UserPay
    f = FreeFile
    Open OutPutFile For Binary As #f
        Put #f, Recordnumber, up
        up.UserDetails.Firstname = txtFirstName.Text
        up.Pay = Val(txtHoursWorked.Text) * Val(txtPayRate.Text)
    Close #f
End Sub
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Post your closing recommendations!  No comment means you don't care.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.