|
-
Dec 4th, 2000, 09:26 AM
#1
Thread Starter
Hyperactive Member
Hi I need to check that the number of lines produced in a .dat file is the same as the number of records in a access db table.
I just want to open the .dat file and count the lines. I tried this but it got stuck in a loop. Why ?
what did I do wrong.
Private Sub Command1_Click()
Dim filenum As Integer
Dim num As Long
filenum = FreeFile
num = 0
Open "c:\store\imascons.dat" For Input As #filenum
Do Until EOF(filenum)
num = num + 1
MsgBox num
Loop
Close filenum
MsgBox num
End Sub
This didnt work , anyone ?
Thx locutus
-
Dec 4th, 2000, 09:33 AM
#2
Fanatic Member
Looks like you need to read the file in order to get the pointer to move through it. Otherwise it will just count forever.
-
Dec 4th, 2000, 09:35 AM
#3
Don't know...
Try this....
Code:
filenum = FreeFile
num = 0
strVar = ""
Open "c:\store\imascons.dat" For Input As #filenum
Do While Not EOF(filenum)
LineInput #1,strVar
num = num + 1
MsgBox num
Loop
Close filenum
MsgBox num
Just a shot.
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Dec 4th, 2000, 09:52 AM
#4
Lively Member
Count Lines
This will work definatly
Dim FileNumber As Integer
Dim FilePath As String
Dim LineCount As Integer
Dim Data As String
' Initialisation
LineCount = 0
FilePath = "C:\Filename"
FileNumber = FreeFile
' Open the file
Open FilePath For Input Access Read As #FileNumber
' Parse the file
Do Until EOF(FileNumber)
Line Input #FileNumber, Data
LineCount = LineCount + 1
Loop
Close #FileNumber
Ian Frawley
Software Engineer
E-mail [email protected]
BEING IN THERAPY
And yet, having therapy is very much like making love to a beautiful woman. You... get on the couch, string 'em along with some half-lies and evasions, probe some deep dark holes, and then hand over all your money.
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
|