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 140 141 142 143 144 145 146
|
Option Explicit '<--- à mettre obligatoirement de préférence, évite souvent de s'arracher les cheveux !
Dim TblTxt() As New Classe1
Dim Cel As Range
Dim LesRoses0 As Long
Private Sub UserForm_Initialize()
Dim NomPage As String
Dim MPage As MSForms.MultiPage
Dim TxtB As MSForms.textbox
Dim Lbl As MSForms.Label
Dim T
Dim DerLigne As Long
Dim X As Long
Dim K As Long
Dim I As Integer
Set MPage = Me.Controls("MultiPage2")
T = Feuil01.Range("B3:B" & Feuil01.Range("B" & Rows.Count).End(xlUp).Row + 1)
Articles.List = T
'titres des Labels
T = Array("Stock", "Unité", "Prix", "Valeur")
DerLigne = Feuil03.Range("A65536").End(xlUp).Row
For X = 2 To DerLigne
NomPage = Feuil03.Range("B" & X)
'Ajoute une page
Me.MultiPage2.Pages.Add (NomPage)
'Sélectionne la nouvelle page
Me.MultiPage2.Value = Me.MultiPage2.Pages.Count - 1
NomPage = Replace(NomPage, " ", "")
For K = 0 To 3
With MPage.Pages(X - 1) 'Je n'arive pas a rendre ceci dynamique pour qu'il s'éxécute sur chaque page créée
'ajoute un TextBox et un Label
Set TxtB = .Controls.Add("Forms.TextBox.1", "NomPage" & K, True)
Set Lbl = .Controls.Add("Forms.Label.1", "Label" & K, True)
End With
'paramètre le TextBox
With TxtB
.Left = 80 * K + 20
.Top = 42
.Width = 80
.Height = 22
End With
'stocke dans un tableau (je préfère à une collection)'entres une valeur et tu verras apparaître un message
'voir dans le module de classe
I = I + 1
ReDim Preserve TblTxt(1 To I)
Set TblTxt(I).GroupeTextBox = TxtB
'paramètre le TerxtBox
With Lbl
.Caption = T(K)
.Font.Size = 12
.Font.Name = "Tahoma"
.TextAlign = fmTextAlignCenter
.BackStyle = fmBackStyleOpaque
.BorderStyle = fmBorderStyleSingle
.Left = 80 * K + 20
.Top = 24
.Width = 80
.Height = 18
End With
Next K
Next X
Me.MultiPage2.Value = 0
End Sub
Private Sub Articles_Click()
Dim D As String
With Feuil01
D = Articles.Text
Set Cel = Feuil01.Columns("B").Find(what:=D, LookIn:=xlValues, LookAt:=xlWhole)
If Not Cel Is Nothing Then
Ligne = Cel.Row
StkTotal = Feuil01.Range("F" & Ligne).Value
LesRoses0 = Feuil01.Range("F" & Ligne).Value
Prix = Feuil01.Range("D" & Ligne).Value
Unité = Feuil01.Range("C" & Ligne).Value
End If
End With
End Sub
Private Sub CommandButton10_Click()
Unload Me
End Sub
Private Sub MultiPage2_Click(ByVal Index As Long)
Dim Ctrl As Control
'Boucle sur la collection de contrôles
'For Each Ctrl In Me.Controls
'MsgBox Ctrl.Name
'Next Ctrl
End Sub
Private Sub Prix_Change()
If StkTotal = "" Or Prix = "" Then Exit Sub
PrixTotal = StkTotal * Prix
Prix = Format(Prix, "0.00" & " ")
End Sub
Private Sub PrixTotal_Change()
PrixTotal.Text = Format(PrixTotal, "0.00" & " ")
End Sub |
Partager