Public TBox(60) As System.Windows.Forms.TextBox Public VarTrav As String ' Variable de travail ' Chargement des noms des TextBox en table pour pouvoir les charger par Tbox(index) For Each Ctrl As Control In Me.Controls If Ctrl.Name.Substring(0, 2) = "TB" Then ' Chaque TextBox est nommé TB... VarTrav = Ctrl.Name TBox(CInt(Mid(Ctrl.Name, 3, 2))) = CType(Ctrl, System.Windows.Forms.TextBox) End If Next ' Chargement des TextBox j = 0 For i = 0 To 19 If Not DateAff(i) = "" Then j = j + 1 TBox(j).Text = DateAff(i) j = j + 1 TBox(j).Text = Poidsfix(i) j = j + 1 TBox(j).Text = PoidsSD(i) End If Next
T1(1,2) = Textbox2
T1(1,2) = "Textbox2"
dim cControls as new collection 'texte, nom du ctrl cControls.add "zone1", "Textbox1" cControls.add "zone2", "Textbox2" cControls.add "un bouton", "CommandButton1"
dim ctrl as object for each ctrl in me if typeof ctrl is commandbutton then ctrl.caption = cControls.item(ctrl.name) elseif typeof ctrl is textbox then ctrl.Text = cControls.item(ctrl.name) else 'etc.... selon les types endif next ctrl set ctrl = nothing