View Full Version : Texteditor


maniso
08-06-2007, 02:55 PM
Is there someone ho nows how i can find the row and kolom in a textwindow programd in VB6.
I'm writing a controlorprogamme for my CNC machine and want to edit the ISO-code and wont to now the location from the cursor.
:)

Switcher
08-10-2007, 07:28 PM
This is how I do it in VB.net 2005. I know you asked for VB6, maybe it will help?


Private Sub RichTextBox1_SelectionChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles RichTextBox1.SelectionChanged
'Get the line number and colom number and show it
Dim intFirstChar As Integer = Me.RichTextBox1.GetCharIndexFromPosition(New Point(0, 0))
Dim intFirstLine As Integer = Me.RichTextBox1.GetLineFromCharIndex(intFirstChar)
Dim intCharCount As Integer = (Me.RichTextBox1.SelectionStart + Me.RichTextBox1.SelectionLength) - intFirstChar
Dim strFromStart As String = Me.RichTextBox1.Text.Substring(intFirstChar, intCharCount)
Dim intLine As Integer = strFromStart.Split(vbLf).Length


' This is the Row Number
Me.lblLine_Counter.Text = (intFirstLine + intLine)

' This is the Column Number
Me.Label1.Text = "Column: " & (intCharCount - strFromStart.LastIndexOf(vbLf))


End Sub

maniso
08-19-2007, 02:25 AM
Thanks for the help, it just work fine and now i can edit the G-code and find the foult on the richt line
Thanks again