vb动态加载控件怎么判断内容

2024-12-02 00:16:01
推荐回答(2个)
回答(1):

Private Sub Command1_Click()
Dim i As Integer
For i = Text1.LBound To Text1.UBound
    If Text1(i).Text = "1" Then
        MsgBox "Text1(" & i & ")中的文本是1"
    End If
Next
End Sub
Private Sub Form_Load()
Dim i As Integer
Text1(0).Text = 0
For i = 1 To 5
    Load Text1(i)
    Text1(i).Text = i
    Text1(i).Top = Text1(i - 1).Top + 300
    Text1(i).Visible = True
Next i
End Sub

回答(2):

用索引来引用动态加载的控件。