Ok, I've been trying to get this to work for a few weeks now looking up code and trying all kinds of different things.
I am using a different methods to count all the Lines in a textbox. But I need to be able to Input a number and selStart that line. Basically a GoTo Line.... box for my notepad program
The first method is this:
Private Sub Form_Load()
Dim TA_index As Integer
Dim Found As Integer
Dim Linenum As Integer
Dim Pos As Integer
TA_index = MainForm.FileStrip.SelectedItem.Index - 1
If MainForm.TextArea(TA_index).Text = "" Then
lblLines.Caption = "1"
Exit Sub
Else
On Error Resume Next
Found = -1
Linenum = 1
MainForm.TextArea(TA_index).SelStart = Len(MainForm.TextArea(TA_index).Text)
Pos = MainForm.TextArea(TA_index).SelStart
Do Until Found = 0
Found = InStrRev(MainForm.TextArea(TA_index).Text, Chr(10), Pos, 0)
If Found = 0 Then Exit Do
Linenum = Linenum + 1
Pos = Found - 1
Loop
lblLines.Caption = Linenum
End If
'Make FindForm stay ontop of mainform but all remain useable
GoToForm.Show vbModeless, MainForm
End Sub
basically it makes sure there is text, then selects the end then counts all the carriage returns. i found the base code on another site. i can't remember which. but in any case it seems to work for the counting. but for the life of me i can't make it so that i can't input a number into a textbox and hit a command button and select that line or carriage return.
So. I tried using your method to count all the lines and I like it, Its less complex then the way above but how could i make either of these methods to select a specific line.