|
-
Feb 22nd, 2002, 05:53 PM
#1
Thread Starter
Member
How do you count the amount of lines in a txt file?
-
Feb 22nd, 2002, 05:57 PM
#2
Addicted Member
Code:
Open "myfile.csv" For Input As #1
While Not EOF(1)
Line Input #1, foo$
Lines = Lines + 1
Wend
Close #1
MsgBox "Your file had " & Lines & " lines."
-
Feb 22nd, 2002, 05:57 PM
#3
-= B u g S l a y e r =-
Hi there NPerezVB, a sample for u 
VB Code:
Option Explicit
Private Declare Function SendMessageLong Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const EM_GETLINECOUNT = &HBA
Private Sub Text1_Change()
Dim lineCount As Long
On Local Error Resume Next
lineCount = SendMessageLong(Text1.hwnd, EM_GETLINECOUNT, 0&, 0&)
Label1 = Format$(lineCount, "##,###")
End Sub
-
Feb 22nd, 2002, 05:58 PM
#4
-= B u g S l a y e r =-
uh... could swear it said text box
-
Feb 22nd, 2002, 06:00 PM
#5
-= B u g S l a y e r =-
VB Code:
Option Explicit
Private Sub Command1_Click()
MsgBox GetNumLines("C:\TEST.TXT")
End Sub
Private Function GetNumLines(sFileName) As Integer
Open sFileName For Binary As #1
GetNumLines = UBound(Split(Input(LOF(1), 1), vbCrLf)) + 1
Close #1
End Function
-
Feb 22nd, 2002, 06:02 PM
#6
Fanatic Member
Actually, Peet
Do you think you can help us with this problem:
http://www.vbforums.com/showthread.p...hreadid=146098
We are considering counting lines in an RTF box.
-
Feb 22nd, 2002, 06:12 PM
#7
-= B u g S l a y e r =-
the answer is the same for RTBoxes as Text boxes HaxSoft, just change the Text1 to RichTextBox1
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
|