|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
I want to use a For Next loop to process the info in a text file. To do that I think I need an upper limit number. So I want to count the number of records in the file. How can I do that. I thought something like the below would work but it didn't.
Option Explicit Dim NumRecords As Integer Private Sub cmdCountRecords_Click() If Not EOF(1) Then NumRecords = NumRecords + 1 Else End If picOutput.Print "Number of Records = "; NumRecords End Sub Private Sub Form_Load() If Right(App.Path, 1) <> "\" Then Open App.Path & "\ModifiedMIM.txt" For Input As #1 Else Open App.Path & "ModifiedMIM.txt" For Input As #1 End If End Sub |
|
#2
|
||||
|
||||
|
hey...
Have you considered using a filesystemobject (fso) instead of opening the .txt for read? Using a reference to the FSO library in Visual Basic lends you some more functionality in dealing with files. If you don't want to go that route (it's kinda tricky, but well worth it once you figure it out), then you will most likely have to loop through the characters individually and look for a VBCRLF. good luck try these http://msdn.microsoft.com/library/d...eprocessing.asp http://msdn.microsoft.com/library/d...objectmodel.asp
__________________
Fisherman "Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius -- and a lot of courage -- to move in the opposite direction." - A.Einstein |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > How to Count Records/Rows in a text file |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|