Public Function checkrow() As String
Dim row As Integer = Me.TextBox1.SelectionStart
Dim i As Integer
Dim p As Integer
Dim count As Integer = 0
Dim count1 As Integer = 0
For i = 0 To Me.TextBox1.Lines.GetUpperBound(0)
count += Me.TextBox1.Lines(i).Length + 2 ' 一个回车相当于2个
If row <= count Then
If i = 0 Then
p = row
Else
p = row - count1
End If
Return "行:" & CStr(i) & "/列:" & CStr(p)
End If
count1 += Me.TextBox1.Lines(i).Length + 2
Next
End Function
本文介绍了一种VBScript方法,用于确定文本编辑器中光标所在的具体行和列位置。通过计算每行文本的长度及光标偏移量,该函数能够准确返回光标所在的行号和列号。
3832

被折叠的 条评论
为什么被折叠?



