1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
'dans un Userform :
'1 multipage nommé Multipage1 , contenant 2 pages
'dans la 1ere page : un Textbox1 et un CommandButton
'
'Saisissez dans le Textbox1 le nombre de frames à créer
'puis lancez la procédure
'
Private Sub CommandButton1_Click()
Dim Pge As Page
Dim Frme As Control, TxtB As Control
Dim x As Byte, j As Byte, i As Byte
If TextBox1 = "" Or Not IsNumeric(TextBox1) Then Exit Sub
x = TextBox1
Set Pge = Me.MultiPage1.Pages(1) '2eme page du multipage
For j = 1 To x 'boucle pour créer les frames
Set Frme = Pge.Controls.Add("Forms.Frame.1")
With Frme
.Left = 10 + ((j - 1) * 100)
.Top = 10
.Width = 90
.Height = 250
End With
For i = 1 To 5 'boucle pour créer les Textbox
Set TxtB = Frme.Add("forms.Textbox.1")
With TxtB
.Left = 5
.Top = 10 + ((i - 1) * 50)
.Width = 75
.Height = 30
End With
Next i
Next j
End Sub |
Partager