?
Solved

Creating sequential file using Visual Basic 6.0

Posted on 2003-03-18
6
Medium Priority
?
351 Views
Last Modified: 2010-04-17
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.
0
Comment
Question by:LakeshaJ
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 

Author Comment

by:LakeshaJ
ID: 8162594
This question needs to be answer ASAP
0
 
LVL 2

Accepted Solution

by:
Jacamar earned 1000 total points
ID: 8162953
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

0
 
LVL 2

Expert Comment

by:Jacamar
ID: 8162967
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"

or

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

eg.

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.
0
 
LVL 76

Assisted Solution

by:GrahamSkan
GrahamSkan earned 1000 total points
ID: 8165860
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
0
 

Expert Comment

by:CleanupPing
ID: 9447019
LakeshaJ:
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 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0

Featured Post

New feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
Progress
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question