|
-
Jan 30th, 2006, 09:16 AM
#1
Thread Starter
New Member
Goto line in text box
In a text box, how do you get it to have the selecting thing (no clue what its called) to start at the beginning of a line if you input a line number into a textbox?
Or easier to say, how would I go about doing goto like in Notepad?
-
Jan 30th, 2006, 09:27 AM
#2
Re: Goto line in text box
See Post #2 in this thread. Is this what you mean?
-
Jan 30th, 2006, 09:41 AM
#3
Re: Goto line in text box
VB Code:
Private Declare Function SendMessage _
Lib "user32.dll" Alias "SendMessageA" ( _
ByVal hWnd As Long, _
ByVal wMsg As Long, _
ByVal wParam As Long, _
ByRef lParam As Any _
) As Long
Private Const EM_LINEINDEX As Long = &HBB
Public Sub GotoLine(txtBox As TextBox, ByVal nLineNumber As Long)
If nLineNumber > 0 Then
txtBox.SelStart = SendMessage(txtBox.hWnd, EM_LINEINDEX, nLineNumber - 1, ByVal 0)
End If
End Sub
Simply call this sub like this:
VB Code:
Call GotoLine(Text1, 3) 'jump to line 3 in the textbox named Text1
-
Mar 25th, 2006, 12:49 PM
#4
Junior Member
Re: Goto line in text box
I'm no expert but this is my solution.
Dim ss As Integer = 0
Dim gotoLineNumber As Integer ' put line number to goto in here
Dim LineIndex As Integer = 0
Dim i As Integer
While LineIndex <> gotoLineNumber - 1
For i = 0 To MainForm.TextBox1.Lines(LineIndex).Length + 1
ss += 1
Next
LineIndex += 1
End While
MainForm.TextBox1.SelectionStart = ss
-
Mar 25th, 2006, 01:12 PM
#5
Re: Goto line in text box
@akagn: What you have supplied is VB.Net code, but this is the Classic VB Forum and the TextBox in Classic VB doesn't have a Lines property.
-
Apr 1st, 2006, 03:33 PM
#6
Junior Member
Re: Goto line in text box
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
|