|
-
Oct 8th, 2003, 10:52 AM
#1
Thread Starter
Frenzied Member
Line Counter
This counts the lines in one RTB and displays it in another
Place 2 rtb's on your form, call one of them txtLinecounter, and the other one txtMain
Then insert this code:
VB Code:
'Declaring Sendmessage API
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const EM_GETLINECOUNT = &HBA
'Declaring oldline
Public Oldline As Integer
Private Sub Form_Load()
'Setting a default value for the RTB(Could do a _Change here instead)
txtLinecounter.Text = "1"
End Sub
Private Sub txtMain_Change()
Dim iLines As Long
Dim i As Integer
iLines = SendMessage(txtMain.hwnd, EM_GETLINECOUNT, 0, 0)
If Not iLines = Oldline Then
txtLinecounter.Text = ""
For i = 1 To iLines
txtLinecounter.Text = txtLinecounter.Text & i & vbCrLf
Next
txtLinecounter.SelStart = InStr(1, Liner, iLines - 1)
Oldline = iLines
Else
Oldline = iLines
End If
End Sub
Hope you like it, I remember having a lot trouble making this when i started doing VB(This one took 10 mins )
Last edited by vbNeo; Oct 8th, 2003 at 12:54 PM.
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
-
Oct 27th, 2003, 10:12 AM
#2
Addicted Member
thanks for sharing, i was looking for something like this.
-
Oct 27th, 2003, 10:20 AM
#3
Thread Starter
Frenzied Member
=)
No problem!
You might have some problems when wanting the boxes to scroll at the same time - i'm working on a way to fix this.
Cheers!
"Lies, sanctions, and cruise missiles have never created a free and just society. Only everyday people can do that."
- Zack de la Rocha
Hear me roar.
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
|