|
-
May 9th, 2001, 10:31 AM
#1
Thread Starter
Junior Member
headers in a text file
I need to ouput a file with a control block (header). In the form_load, I am setting my control block. My problem is that line eight must be the total of all records added from the sub AuditMe. I tried line input and either it doesn't work or I did it wrong. All the sub procedures involved are listed below. Any suggestions on how to do this?
Thanks
Private Sub Form_Load()
Call dbconnect
Call objectcmd
On Error Resume Next
Kill "c:\testing\mispunch.txt"
On Error Resume Next
Kill "c:\testing\kronos.dat"
myrecCnt = 0
myrs.MoveFirst
Open "c:\testing\mispunch.txt" For Append As #1
Open "c:\testing\Kronos.dat" For Append As #2
Print #2, "00"
Print #2, "0000000000"
Print #2, "0000000000"
Print #2, "0000000000"
Print #2, "0000000000"
Print #2, "0000000000"
Print #2, myrecCnt
Print #2, "0000000001"
Print #2, Spc(168); "32"
Call loopy
End Sub
Public Sub output()
Dim myfor As String
myfor = Format(newAdj, "00##")
myrecCnt = Format(myrecCnt, "0##########")
Print #2, "02"
Print #2, Spc(10)
Print #2, empnum
Print #2, mydate
Print #2, "0100"
Print #2, "999"
Print #2, Spc(12)
Print #2, "REG"; Spc(6)
Print #2, myfor
Print #2, adsb
Print #2, "00"
Print #2, "00"
Print #2,
End Sub
Public Sub AuditMe()
audAmt = 0
newAdj = 0
Do While Not myrsaud.EOF
If mydate = myrsaud("date") And empnum = myrsaud("empnum") Then
audAmt = (myrsaud("amnt") + audAmt)
End If
myrsaud.MoveNext
Loop
If audAmt <> breaktime Then
newAdj = breaktime - audAmt
myrecCnt = myrecCnt + 1
If newAdj < 0 Then
adsb = "01"
Else
adsb = "00"
End If
If newAdj < 0 Then
newAdj = newAdj * -1
End If
Call output
End If
myrsaud.MoveFirst
End Sub
I wanted to say something profound and
all I came up with is this -->> "Eat dessert
first, life is short"
-
May 9th, 2001, 10:39 AM
#2
Retired VBF Adm1nistrator
All file I/O / text manipulation is pretty easy once you get used to it. But I dont understand what you're trying to do ....
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
May 9th, 2001, 10:59 AM
#3
Thread Starter
Junior Member
When the code exe, the auditme sub is called to verify if any changes are needed.
this then calls the output sub and adds the information based on the variables assigned to each line (print#2, empnum)
In the form load event, I have to have this control block (header). Line eight must contain the total number of records for input into another application (myreccnt is my variable for this) It counts in the auditme sub.
I open the file set the control block.
The auditme sub runs until EOF appends the records to Kronos.Dat.
How do I now I change line 8 of the control block to relfect the number of records added? I added a counter, but I don't know how to tell the control block that line 8 is changed and to accepted the value of myreccnt.
I wanted to say something profound and
all I came up with is this -->> "Eat dessert
first, life is short"
-
May 9th, 2001, 11:07 AM
#4
Retired VBF Adm1nistrator
I dont know if I fully get at what you're saying, but something like this might do it :
Code:
Dim strTemp1 As String
Dim strTemp2() As String
Open "c:\some file.txt" For Binary As #1
strTemp1 = Input(LOF(1), 1)
strTemp2 = Split(strTemp1, vbCrLf)
strTemp2(7) = NewNumberGoesHere '8th line
strTemp1 = Join(strTemp2, vbCrLf)
Close #1
Open "c:\other file.txt" For Output As #1
Print #1, strTemp1
Close #1
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|