VB将数据指点到数组进行添加

2024年11月30日 00:30
有1个网友回答
网友(1):

假定“数据记录3”是控件数组Text1,“字符累计4”是控件数组Text2,“数据输入1”是Text3,“指点位置2”是Text4,按钮是Command1,则

Private Sub Command1_Click()
Dim s As Long, i As Long, j As Long
For i = Text2.LBound To Text2.UBound
If Val(Text2(i).Text) = Val(Text4.Text) Then Exit For
Next
If i <= Text2.UBound Then
For j = Text1.UBound To i + 1 Step -1
Text1(j).Text = Text1(j - 1).Text
Next
Text1(i).Text = Text3.Text
For i = Text1.LBound To Text1.UBound
s = s + Len(Text1(i).Text)
Text2(i).Text = s
Next
End If
End Sub