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
//////////////////////////// 闵峰

博客展示了一段VB代码,定义了一个名为checkrow的公共函数,用于检查文本框中当前位置的行和列。函数通过遍历文本框的每一行,计算字符数量,根据当前选择位置确定所在行和列,并返回相应信息。
8549

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



