look at the subject
Printable View
look at the subject
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."
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
uh... could swear it said text box :(
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
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.
the answer is the same for RTBoxes as Text boxes HaxSoft, just change the Text1 to RichTextBox1 :)