Numbering Text Area Lines

trescott
05-31-2004, 06:27 PM
Is it possible to number the lines of a text area with Visual Basic .NET?

bear24rw
05-31-2004, 06:28 PM
what exactly do you mean?

trescott
05-31-2004, 06:29 PM
I'm working on a text file code editor that will consist of a text area, but would like to number the lines inside of it for reference purposes.

Paszt
05-31-2004, 07:20 PM
I think the best way would be to create a composite control made up of two textboxes that communicate to each other. Each time the main textBox (the one the user would type into) has a new line, put a new line in the lineNumber textbox with the line number.

CMG
06-02-2004, 06:18 AM
Here ya go:


Private Sub numberlines(ByVal t As TextBox)
Dim strTmp() As String = t.Text.Split(vbCrLf)
t.Text = ""
For i As Integer = 0 To UBound(strTmp)
t.Text &= i & ".: " & strTmp(i).Trim & vbCrLf
Next
End Sub

TextBox1.Text = "Testing" & vbCrLf & "Testing" & vbCrLf & "Testing" & vbCrLf & "Testing" & vbCrLf & "Testing" & vbCrLf & "Testing" & vbCrLf & "Testing" & vbCrLf & "Testing" & vbCrLf & "Testing" & vbCrLf & "Testing" & vbCrLf & "Testing" & vbCrLf & "Testing" & vbCrLf & "Testing" & vbCrLf & "pff"
numberlines(TextBox1)

trescott
06-02-2004, 09:23 AM
Thanks!

CMG
06-02-2004, 01:46 PM
Thanks!
No Problem, hope this works for you :)

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum