通过多行文本框建立索引

Indexing through Multiline Textbox

我想弄清楚如何通过使用多行文本框填充的字符串编制索引。我需要遍历文本框的每一行以确定每行中的字符数。

到目前为止,我的代码从文本框中提取文本并将其拆分。行数可以是 2 到 8 之间的任意值。我不确定如何对字符串进行索引以查找 array/text 的大小和长度。我尝试使用 Ubound 获取行数并使用 Len 获取每行的长度,但似乎无法让它们工作。

 Dim Marking As String
 Dim Lines As String 
 Dim LineCount As Integer
 Dim LineWidthTemp as Integer
 Dim LineWidth as Integer
 Dim LineIndex as Integer

 Marking = UserForm1.Stencil.Text
 Lines = Split(Marking, vbCrLf)
 LineCount = UBound(Lines()) + 1

 For Lines(1) To Lines(LineCount)
    LineWidthTemp = Len(LineIndex)
    If LineWidthTemp > LineWidth Then
    LineWidth = LineWidthTemp
    Else
 Next

最终的结果应该是可以使用数组长度对所有行进行索引,确定所有行的字符长度,并保存最大的量。

像这样的东西会起作用:

Dim l As Variant, maxLen As Long

For Each l In Split(Me.Stencil.Text, vbCrLf)
    Debug.Print l, Len(l)
    If Len(l) > maxLen Then maxLen = Len(l)
Next l