Get the index of the caret in the TextBox:
C#
int caretIndex = textBox.SelectionStart;
VB.NET
Dim caretIndex As Integer = textBox.SelectionStart
Get the line number from the caret index:
C#
int lineNumber = textBox.GetLineFromCharIndex(caretIndex);
VB.NET
Dim lineNumber As Integer = textBox.GetLineFromCharIndex(caretIndex)
Get the character index in the current line:
C#
Point characterXY = textBox.GetPositionFromCharIndex(caretIndex);
int characterIndex = textBox.GetCharIndexFromPosition(characterXY);
VB.NET
Dim characterXY As Point = textBox.GetPositionFromCharIndex(caretIndex)
Dim characterIndex As Integer = textBox.GetCharIndexFromPosition(characterXY)