This is how I do it in VB.net 2005. I know you asked for VB6, maybe it will help?
Code: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


LinkBack URL
About LinkBacks




