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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139
|
Option Explicit
Dim Txt() As New ClasBT
Dim Cmb() As New ClasBT
Private Sub UserForm_Initialize()
Dim compteur2 As Integer
Dim frm As MSForms.Frame
Dim lb1 As MSForms.Label
Dim lb2 As MSForms.Label
Dim TxtPoidsproduitcalculé As MSForms.TextBox
Dim TxtPoidsproduitimposé As MSForms.TextBox
Dim Cbxpoidscouleur As ComboBox
Dim plage As String
Dim I As Integer
plage = Sheets("feuille de saisie").Range("p4:p7").Address
With masque2
' .StartUpPosition = 3
' .Width = Application.Width - 2
' .Height = Application.Height - 3
End With
For compteur2 = 1 To Sheets("Feuille de Saisie").Range("E3").Value 'boucle pour créer les frames
Set frm = masque2.Controls.Add("Forms.Frame.1")
With frm
.Left = 300 + ((compteur2 - 1) * 172)
.Top = 78
.Width = 162
.Height = 350
.Caption = "produit " & Chr(64 + compteur2)
End With
'------ Créer le Label 1---------------------
Set lb1 = frm.Add("Forms.Label.1", "Label1", True)
With lb1
.AutoSize = False
.BackStyle = 1
.BorderColor = &H80000012
.BackColor = &H8000000F
.BorderStyle = fmBorderStyleNone
.FontSize = 8
.FontBold = True
.TextAlign = fmTextAlignCenter
.Left = 70
.Top = 50
.Width = 50
.Height = 18
.Caption = "calculée :"
End With
'------ Créer le Label 2---------------------
Set lb2 = frm.Add("Forms.Label.1", "Label2", True)
With lb2
.AutoSize = False
.BackStyle = 1
.BorderColor = &H80000012
.BackColor = &H8000000F
.BorderStyle = fmBorderStyleNone
.FontSize = 8
.FontBold = True
.TextAlign = fmTextAlignCenter
.Left = 20
.Top = 50
.Width = 50
.Height = 18
.Caption = "imposée :"
End With
'------ Créer le Txtbox qui récupère le poid par produit calculé ---------------------
Set TxtPoidsproduitcalculé = frm.Add("forms.Textbox.1")
With TxtPoidsproduitcalculé
.Left = 70
.Top = 60
.Width = 50
.Height = 18
.Name = "TxtPoidsproduitcalculé" & Chr(64 + compteur2)
.Value = Round(Sheets("Feuille de Saisie").Cells(5, compteur2 * 2 + 1).Value, 2)
End With
'------ Créer le Txtbox ou l'on saisi le poid par produit imposé ---------------------
Set TxtPoidsproduitimposé = frm.Add("forms.Textbox.1", "TxtPoidsproduitimposé" & Chr(64 + compteur2))
With TxtPoidsproduitimposé
.Left = 20
.Top = 60
.Width = 50
.Height = 18
.Tag = Chr(64 + compteur2 * 2) & 5
End With
I = I + 1
ReDim Preserve Txt(1 To I)
Set Txt(I).Texte = TxtPoidsproduitimposé
'------ Créer le combo qui récupère les couleurs et les affecte aux produits --------------------
Set Cbxpoidscouleur = frm.Add("forms.combobox.1", "Cbxpoidscouleur" & Chr(64 + compteur2))
With Cbxpoidscouleur
.Left = 6
.Top = 6
.AddItem ("rouge")
.AddItem ("bleu")
.AddItem ("vert")
.AddItem ("jaune")
.Width = 50
.Height = 18
.Tag = Chr(64 + compteur2 * 2) & 6
End With
ReDim Preserve Cmb(1 To I)
Set Cmb(I).cb = Cbxpoidscouleur
Next compteur2
End Sub |
Partager