Dim insuu As Integer = RichTextBox1.SelectionStart Dim from_the_beginning_of_the_line As Integer = 0 Dim oun_line As Integer = 0 Dim n() As String = Split(RichTextBox1.Text, vbCrLf) Dim ni As Integer = 0 Dim maxn As Integer = 0 ' n.Length - 1 For i = 0 To n.Length - 1 oun_line = 0 If n(ni) Is "" Then ' maxn += 1 Else oun_line = n(ni).Length maxn += n(ni).Length End If If maxn >= insuu Then 'ここで、入ってきた数が大きくなったら、カーソール越した ni が行で、n(ni).Length-(maxn-insuu)行頭から現在の位置 from_the_beginning_of_the_line = n(ni).Length - (maxn - insuu) Exit For End If maxn += 2 ni += 1 Next
Dim answer As Integer = maxn 'ここか Dim Number_of_line_breaks As Integer = n.Length
ありがとうございます。 2023/09/16 (Sat) 21:01:17
Dim from_the_beginning_of_the_line As Integer = 0
Dim oun_line As Integer = 0
Dim n() As String = Split(RichTextBox1.Text, vbCrLf)
Dim ni As Integer = 0
Dim maxn As Integer = 0 ' n.Length - 1
For i = 0 To n.Length - 1
oun_line = 0
If n(ni) Is "" Then
' maxn += 1
Else
oun_line = n(ni).Length
maxn += n(ni).Length
End If
If maxn >= insuu Then
'ここで、入ってきた数が大きくなったら、カーソール越した ni が行で、n(ni).Length-(maxn-insuu)行頭から現在の位置
from_the_beginning_of_the_line = n(ni).Length - (maxn - insuu)
Exit For
End If
maxn += 2
ni += 1
Next
Dim answer As Integer = maxn 'ここか
Dim Number_of_line_breaks As Integer = n.Length