Option Explicit
Private WithEvents CL As ComboBoxLiées, LCou As Long, TVL()
Private Sub UserForm_Initialize()
Set CL = Création.ComboBoxLiées
CL.Plage [TblBaseArticles]
CL.Add CBxRefArticle, 1
CL.Add CBxFamille, 2
CL.Add CBxSousFamille, 3
CL.Add CBxDésignation, 4
CL.Add CBxFournisseur, 5
CL.CouleurSympa
CL.Actualiser
End Sub
Private Sub CL_Change(ByVal Complet As Boolean, ByVal NbrLgn As Long)
If NbrLgn = 1 Then Exit Sub
LCou = 0
ReDim TVL(1 To 1, 1 To 16)
GarnirAutresContrôles
End Sub
Private Sub CL_BingoUn(ByVal Ligne As Long)
LCou = Ligne
TVL = CL.Lignes(LCou).Range.Value
GarnirAutresContrôles
End Sub
Private Sub GarnirAutresContrôles()
TBxLongueurColisage.Text = TVL(1, 6)
TBxLargeurColisage.Text = TVL(1, 7)
TVL(1, 8) = TBxHauteurColisage.Text
TBxCrééLe = TVL(1, 9)
TBxNotes.Text = TVL(1, 10)
TBxDelaisLivraison.Text = TVL(1, 11)
TBxFraisTransport.Text = TVL(1, 12)
TBxFacturation.Text = TVL(1, 13)
CBxModeDeGestion.Text = TVL(1, 14)
TBxMiniCommande.Text = TVL(1, 15)
TBxPrixUnitHT.Text = TVL(1, 16)
End Sub
Private Sub CBnEnregistrer_Click()
TVL(1, 6) = ValeurTBx(TBxLongueurColisage)
TVL(1, 7) = ValeurTBx(TBxLargeurColisage)
TVL(1, 8) = ValeurTBx(TBxHauteurColisage)
TVL(1, 9) = Now
TVL(1, 10) = ValeurTBx(TBxNotes)
TVL(1, 11) = ValeurTBx(TBxDelaisLivraison)
TVL(1, 12) = ValeurTBx(TBxFraisTransport)
TVL(1, 13) = ValeurTBx(TBxFacturation)
TVL(1, 14) = ValeurTBx(CBxModeDeGestion)
TVL(1, 15) = ValeurTBx(TBxMiniCommande)
TVL(1, 16) = ValeurTBx(TBxPrixUnitHT, TypDon:=vbCurrency)
If LCou = 0 Then
CL.ValeursVers TVL
CL.Lignes.Add.Range.Value = TVL
CL.Actualiser
Else
CL.Lignes(LCou).Range.Value = TVL
End If
End Sub
Private Function ValeurTBx(ByVal TBx As MSForms.TextBox, Optional ByVal TypDon As VbVarType = vbDouble)
If IsNumeric(TBx.Text) And TypDon <> vbString Then
If TypDon = vbCurrency Then ValeurTBx = CCur(TBx.Text) Else ValeurTBx = CDbl(TBx.Text)
ElseIf TBx.Text = "" Then
ValeurTBx = Empty
Else: ValeurTBx = TBx.Text: End If
End Function