Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open ASCII file 1

Status
Not open for further replies.

DougP

MIS
Dec 13, 1999
5,985
US
I have a file of time clock punches
as show

Badge:000007629 12/26/00 7:31 Sta:1 [0]
Badge:000007653 12/26/00 8:33 Sta:1 [0]
Badge:000007649 12/26/00 15:29 Sta:1 [0]
Badge:000007610 12/26/00 15:30 Sta:1 [0]
Badge:000007619 12/26/00 15:31 Sta:1 [0]
Badge:000007638 12/26/00 16:30 Sta:1 [0]

It is a history file
The most recent data is at the end
How can I move the record pointer to th eend and work backwards?

I want to use this code if possible or something like it

Open "\\Accserver2\AppsAcc\ATTNPRO\DATA\TRAIL.LOG" For Input As #1
Do While Not EOF(1)


Loop
Close #1
-------------------------

TIA DougP, MCP
 
Use lof() to get the length of the file.
Use seek #x, b to get to the end of the file
where x is the file number and b is lof()
If you know the length of the record and they all fixed
you could use seek #x, (b - length of the record)

Good luck
 
Assuming your record length(s) are fixed, you could place the following code in a module:

************************************
'Define a custom data type
Public Type timeCardData
sVal As String * n 'where "n" is the record length for
'each line of the flat file
End Type
************************************

Then in your form you could place the following code:

************************************
Dim sTime As timeCardData
Dim iRcnt As Integer
Dim iTotRows As Integer


Open "\\Accserver2\AppsAcc\ATTNPRO\DATA\TRAIL.LOG" For Random As #1 Len = Len(sTime)

iRcnt = 0
iTotRows = LOF(1) / Len(sTime)
icnt = LOF(1)

'Gets the rows of data starting from the
'last row
For iRcnt = 0 To iTotRows - 1
Get #1, iTotRows - iRcnt, sTime
MsgBox sTime.sVal
Next

Close #1
*************************************************


Hope this helps.
 
Dude you getting a STAR

Thanks worked perfect
I had to fiddle with the length of the record
40, then 41, then 42 was it
Also had to change "Integer" to "Single" here becasue its big
?LOF(1)
1532748

Dim iRcnt As Integer << Single
Dim iTotRows As Integer << Single

But anyway I'm set now
DougP, MCP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top