per creare una textbox senza l'uso di matrice di controlli
codice:
Private WithEvents txtobj As TextBox
Private Sub Form_Load()
Dim txtobj As TextBox
Call Aggiungi_Textbox("txtRunTime", Me)
Set txtobj = Oggetto("txtRunTime", Me)
txtobj.Left = 100
txtobj.Visible = True
Set txtobjev = txtobj
End Sub
Public Sub Aggiungi_Textbox(sNome As String, NomeForm As Form)
Dim txtControl1 As TextBox
Set txtControl1 = NomeForm.Controls.Add("VB.TextBox", sNome)
End Sub
Public Function Oggetto(sNome As String, NomeForm As Form) As Control
Dim obj As Control
For Each obj In NomeForm.Controls
If obj.Name = sNome Then
Set Oggetto = obj
Exit For
End If
Next
End Function
per clonare una textbox esistente
impostare la propindex a 0
codice:
load text1(1)
text1(1).move posizione
text1(1).visible = True