求助,关于动态添加删除窗体控件
'新增Private Sub Command1_Click()
Static i
i = i + 1
Load Me.Text1(i)
Text1(i).Top = Text1(i - 1).Top + Text1(i - 1).Height
Text1(i).Text = ""
Text1(i).Visible = True
Load Me.Text2(i)
Text2(i).Top = Text2(i - 1).Top + Text2(i - 1).Height
Text2(i).Text = ""
Text2(i).Visible = True
Load Me.Text3(i)
Text3(i).Top = Text3(i - 1).Top + Text3(i - 1).Height
Text3(i).Text = ""
Text3(i).Visible = True
Load Me.Text4(i)
Text4(i).Top = Text4(i - 1).Top + Text4(i - 1).Height
Text4(i).Text = ""
Text4(i).Visible = True
Load Me.Text5(i)
Text5(i).Top = Text5(i - 1).Top + Text5(i - 1).Height
Text5(i).Text = ""
Text5(i).Visible = True
j = i
End Sub
'删除
Private Sub Command2_Click(Index As Integer)
If j < 1 Then Exit Sub
Unload Me.Text1(j)
Unload Me.Text2(j)
Unload Me.Text3(j)
Unload Me.Text4(j)
Unload Me.Text5(j)
j = j - 1
i = i - 1
End Sub
问题是:当把动态添加的控件删除后,再点新增的时候Static i的值是叠加的,老是显示控件数组元素不存在