Sub
Command1_Click()
Dim
x()
As
Integer,
i%,
n%,
k%
ReDim
x(1
To
10)
As
Integer
Form1.Cls
For
i
=
1
To
10
x(i)
=
Int(Rnd()
*
10)
x(i)
Next
i
n
=
Val(Text1)
'插入数字
k
=
Val(Text2)
'插入位置
If
n
>
0
And
k
>
0
And
k
<
11
Then
ReDim
Preserve
x(1
To
11)
As
Integer
For
i
=
(UBound(x)
-
1)
To
(k
-
1)
Step
-1
x(i
+
1)
=
x(i)
Next
i
x(k)
=
n
For
i
=
1
To
11
x(i)
Next
i
Else
MsgBox
"输入数字有误",
vbCritical
End
If
End
Sub
假定“数据记录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
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)