hSindhu
asked on
GoTo line number in text box--VB6.0
Hi,
I am using VB 6.0 for a front end in which i need to have the below functionality--
I have a error log displayed in a text box. If i click on the error which contains the file name and the line number also. when i double click it, i am able open that file in separate text box, but i want to go to that particular line number when the file opens. Either cursor can stop there or highlight the whole line.
Please help me doing this.
Regards,
hSindhu
I am using VB 6.0 for a front end in which i need to have the below functionality--
I have a error log displayed in a text box. If i click on the error which contains the file name and the line number also. when i double click it, i am able open that file in separate text box, but i want to go to that particular line number when the file opens. Either cursor can stop there or highlight the whole line.
Please help me doing this.
Regards,
hSindhu
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks dbrckovi .It worked out.
Try this:
- create two textboxes and a command button
- Set HideSelection property of Text1 to False
- Set Multiline property of Text1 to True
- fill Text1 with some Multiline text
- paste this code:
'-------------------------
Private Sub Command1_Click()
On Error Resume Next
Dim LineStart() As Long
Dim Char As Integer
Dim X As Integer
Dim GotoLine As Integer
GotoLine = Val(Text2.Text)
If GotoLine = 0 Then GotoLine = 1
ReDim LineStart(0 To 1)
LineStart(1) = 0
For X = 1 To Len(Text1.Text)
Char = Asc(Mid(Text1.Text, X, 1))
If Char = Asc(vbCrLf) Then
ReDim Preserve LineStart(UBound(LineStart
LineStart(UBound(LineStart
End If
Next X
Text1.SelStart = LineStart(GotoLine)
If Err <> 0 Then
Text1.SelStart = Len(Text1.Text)
End If
DoEvents
Text1.SelLength = 1
DoEvents
End Sub
'-------------------------
- to use it, enter line number in textbox2, and click the button