mmarle | Bonjour,
Voici le code modifié.
Dans l'Userform:
Code :
- Option Explicit
- '*****************************'
- '* Déclaration des Variables *'
- '*****************************'
- Dim i As Integer
- Dim a As Integer
- Dim LargPav As Byte
- Dim LongPav As Byte
- Dim LargJoint As Single
- Dim EpLi As Single
- Dim Surf As Single
- Dim HautPav As Byte
- Dim DosageA As Integer
- Dim DosageB As Integer
- Private Sub ComboBox1_Click()
- '*********************'
- '* Largeur des Pavés *'
- '*********************'
- If ComboBox1 <> "" Then
- LargPav = Left(ComboBox1.Value, Len(ComboBox1) - 3)
- TextBox2 = CalcA(LargPav, LongPav, LargJoint)
- TextBox3 = CalcB(LargPav, LongPav, LargJoint)
- TextBox4 = CalcC(LargPav, LongPav, LargJoint, Surf)
- TextBox5 = CalcD(LargPav, LongPav, LargJoint, Surf)
- TextBox8 = CalcG(LargPav, LongPav, LargJoint, Surf, HautPav)
- TextBox9 = CalcH(LargPav, LongPav, LargJoint, Surf, HautPav, DosageB)
- Else
- LargPav = 0
- TextBox2 = ""
- TextBox3 = ""
- TextBox4 = ""
- TextBox5 = ""
- TextBox8 = ""
- TextBox9 = ""
- End If
- End Sub
- Private Sub ComboBox2_Click()
- '**********************'
- '* Longueur des Pavés *'
- '**********************'
- If ComboBox2 <> "" Then
- LongPav = Left(ComboBox2.Value, Len(ComboBox2) - 3)
- TextBox2 = CalcA(LargPav, LongPav, LargJoint)
- TextBox3 = CalcB(LargPav, LongPav, LargJoint)
- TextBox4 = CalcC(LargPav, LongPav, LargJoint, Surf)
- TextBox5 = CalcD(LargPav, LongPav, LargJoint, Surf)
- TextBox8 = CalcG(LargPav, LongPav, LargJoint, Surf, HautPav)
- TextBox9 = CalcH(LargPav, LongPav, LargJoint, Surf, HautPav, DosageB)
- Else
- LongPav = 0
- TextBox2 = ""
- TextBox3 = ""
- TextBox4 = ""
- TextBox5 = ""
- TextBox8 = ""
- TextBox9 = ""
- End If
- End Sub
- Private Sub ComboBox3_Change()
- '*********************'
- '* Hauteur des Pavés *'
- '*********************'
- If ComboBox3 <> "" Then
- HautPav = Left(ComboBox3.Value, Len(ComboBox3) - 3)
- TextBox8 = CalcG(LargPav, LongPav, LargJoint, Surf, HautPav)
- TextBox9 = CalcH(LargPav, LongPav, LargJoint, Surf, HautPav, DosageB)
- Else
- HautPav = 0
- TextBox8 = ""
- TextBox9 = ""
- End If
- End Sub
- Private Sub ComboBox4_Click()
- '**********************'
- '* Largeur des Joints *'
- '**********************'
- If ComboBox4 <> "" Then
- LargJoint = Left(ComboBox4.Value, Len(ComboBox4) - 3) / 10
- TextBox2 = CalcA(LargPav, LongPav, LargJoint)
- TextBox3 = CalcB(LargPav, LongPav, LargJoint)
- TextBox4 = CalcC(LargPav, LongPav, LargJoint, Surf)
- TextBox5 = CalcD(LargPav, LongPav, LargJoint, Surf)
- TextBox8 = CalcG(LargPav, LongPav, LargJoint, Surf, HautPav)
- TextBox9 = CalcH(LargPav, LongPav, LargJoint, Surf, HautPav, DosageB)
- Else
- LargJoint = 0
- TextBox2 = ""
- TextBox3 = ""
- TextBox4 = ""
- TextBox5 = ""
- TextBox8 = ""
- TextBox9 = ""
- End If
- End Sub
- Private Sub ComboBox5_Change()
- '*************************'
- '* Epaisseur Lit de Pose *'
- '*************************'
- If ComboBox5 <> "" Then
- EpLi = (Left(ComboBox5.Value, Len(ComboBox5) - 3)) / 100
- TextBox6 = CalcE(Surf, EpLi)
- TextBox7 = CalcF(Surf, EpLi, DosageA)
- Else
- EpLi = 0
- TextBox6 = ""
- TextBox7 = ""
- End If
- End Sub
- Private Sub ComboBox6_Change()
- '*************************************'
- '* Dosage en Ciment pour Lit de Pose *'
- '*************************************'
- If ComboBox6 <> "" Then
- DosageA = Left(ComboBox6.Value, Len(ComboBox6) - 6)
- TextBox7 = CalcF(Surf, EpLi, DosageA)
- Else
- DosageA = 0
- TextBox7 = ""
- End If
- End Sub
- Private Sub ComboBox7_Click()
- '********************************'
- '* Dosage en Ciment pour joints *'
- '********************************'
- If ComboBox7 <> "" Then
- DosageB = Left(ComboBox7.Value, Len(ComboBox7) - 6)
- TextBox9 = CalcH(LargPav, LongPav, LargJoint, Surf, HautPav, DosageB)
- Else
- DosageB = 0
- TextBox9 = ""
- End If
- End Sub
- Private Sub CommandButton1_Click()
- '*****************'
- '* Bouton Fermer *'
- '*****************'
- 'Ferme RatioBox'
- Unload RatioBox
- End Sub
- Private Sub TextBox1_AfterUpdate()
- '*************************'
- '* Mise en Forme Surface *'
- '*************************'
- TextBox1 = Format(TextBox1, "# ### ##0.00 m²" )
- If TextBox1 <> "" Then
- Surf = Left(TextBox1.Value, Len(TextBox1.Value) - 3)
- TextBox4 = CalcC(LargPav, LongPav, LargJoint, Surf)
- TextBox5 = CalcD(LargPav, LongPav, LargJoint, Surf)
- TextBox6 = CalcE(Surf, EpLi)
- TextBox7 = CalcF(Surf, EpLi, DosageA)
- TextBox8 = CalcG(LargPav, LongPav, LargJoint, Surf, HautPav)
- TextBox9 = CalcH(LargPav, LongPav, LargJoint, Surf, HautPav, DosageB)
- Else
- Surf = ""
- TextBox4 = ""
- TextBox5 = ""
- TextBox6 = ""
- TextBox7 = ""
- TextBox8 = ""
- TextBox9 = ""
- End If
- End Sub
- Private Sub TextBox2_Change()
- '*****************************'
- '* Mise en Forme Ratio Pavés *'
- '*****************************'
- TextBox2 = Format(TextBox2, "#.00 %" )
- Select Case CalcA(LargPav, LongPav, LargJoint)
- Case Is = 0
- TextBox2 = ""
- Case Is = 1
- TextBox2 = ""
- End Select
- End Sub
- Private Sub TextBox3_Change()
- '******************************'
- '* Mise en Forme Ratio Joints *'
- '******************************'
- TextBox3 = Format(TextBox3, "#.00 %" )
- Select Case CalcB(LargPav, LongPav, LargJoint)
- Case Is = 0
- TextBox3 = ""
- Case Is = 1
- TextBox3 = ""
- End Select
- End Sub
- Private Sub TextBox4_Change()
- '*******************************'
- '* Mise en Forme Surface Pavés *'
- '*******************************'
- TextBox4 = Format(TextBox4, "# ##0.00 m²" )
- Select Case CalcC(LargPav, LongPav, LargJoint, Surf)
- Case Is = 0
- TextBox4 = ""
- Case Is = 1
- TextBox4 = ""
- End Select
- End Sub
- Private Sub TextBox5_Change()
- '********************************'
- '* Mise en Forme Surface Joints *'
- '********************************'
- TextBox5 = Format(TextBox5, "# ##0.00 m²" )
- Select Case CalcD(LargPav, LongPav, LargJoint, Surf)
- Case Is = 0
- TextBox5 = ""
- Case Is = 1
- TextBox5 = ""
- End Select
- End Sub
- Private Sub TextBox6_Change()
- '************************************'
- '* Mise en Forme Volume Lit de Pose *'
- '************************************'
- TextBox6 = Format(TextBox6, "# ##0.00 m3" )
- Select Case CalcE(Surf, EpLi)
- Case Is = 0
- TextBox6 = ""
- Case Is = 1
- TextBox6 = ""
- End Select
- End Sub
- Private Sub TextBox7_Change()
- '********************************************************'
- '* Mise en Forme Nbre de Sac de Ciment pour Lit de Pose *'
- '********************************************************'
- 'TextBox7 = TextBox7
- Select Case CalcF(Surf, EpLi, DosageA)
- Case Is = 0
- TextBox7 = ""
- Case Is = 1
- TextBox7 = ""
- End Select
- End Sub
- Private Sub TextBox8_Change()
- '*******************************'
- '* Mise en Forme Surface Pavés *'
- '*******************************'
- TextBox8 = Format(TextBox8, "# ##0.00 m3" )
- Select Case CalcG(LargPav, LongPav, LargJoint, HautPav, Surf)
- Case Is = 0
- TextBox8 = ""
- Case Is = 1
- TextBox8 = ""
- End Select
- End Sub
- Private Sub TextBox9_Change()
- Select Case CalcH(LargPav, LongPav, LargJoint, HautPav, Surf, DosageB)
- Case Is = 0
- TextBox9 = ""
- Case Is = 1
- TextBox9 = ""
- End Select
- End Sub
- Private Sub UserForm_Initialize()
- '***************************'
- '* Initialisation RatioBox *'
- '***************************'
- 'Initialisation Largeur des Pavés'
- With ComboBox1
- .AddItem ""
- End With
- 'Initialisation Longueur des Pavés'
- With ComboBox2
- .AddItem ""
- End With
- For i = 5 To 100
- 'Initialisation Largeur des Pavés'
- With ComboBox1
- .AddItem Format(i, "#.00 cm" )
- End With
- 'Initialisation Longueur des Pavés'
- With ComboBox2
- .AddItem Format(i, "#.00 cm" )
- End With
- Next i
- 'Initialisation Hauteur des Pavés'
- With ComboBox3
- .AddItem ""
- .AddItem Format(6, "#.00 cm" )
- .AddItem Format(8, "#.00 cm" )
- .AddItem Format(14, "#.00 cm" )
- .AddItem Format(20, "#.00 cm" )
- End With
- 'Initialisation Largeur des Joints'
- With ComboBox4
- .AddItem ""
- .AddItem 8 & " mm"
- .AddItem 10 & " mm"
- .AddItem 15 & " mm"
- .AddItem 20 & " mm"
- .AddItem 25 & " mm"
- .AddItem 30 & " mm"
- .AddItem 35 & " mm"
- .AddItem 40 & " mm"
- End With
- 'Initialisation Epaisseur Lit de Pose'
- With ComboBox5
- .AddItem ""
- End With
- 'Initialisation Dosage Ciment'
- For i = 3 To 6
- With ComboBox5
- .AddItem Format(i, " #.00 cm" )
- End With
- Next i
- 'Initialisation Dosage Ciment'
- With ComboBox6
- .AddItem ""
- End With
- 'Initialisation Dosage Ciment'
- For a = 100 To 500 Step 25
- With ComboBox6
- .AddItem a & " Kg/m3"
- End With
- Next a
- 'Initialisation Dosage Ciment'
- With ComboBox7
- .AddItem ""
- End With
- 'Initialisation Dosage Ciment'
- For a = 100 To 500 Step 25
- With ComboBox7
- .AddItem a & " Kg/m3"
- End With
- Next a
- 'Saisie dans TextBox désactivée'
- TextBox2.Enabled = False
- TextBox3.Enabled = False
- TextBox4.Enabled = False
- TextBox5.Enabled = False
- TextBox6.Enabled = False
- TextBox7.Enabled = False
- TextBox8.Enabled = False
- TextBox9.Enabled = False
- End Sub
|
Dans un module:
Code :
- Option Explicit
- Function CalcA(LargPav, LongPav, LargJoint)
- 'Calcul du Pourcentage de Pavés'
- On Error Resume Next
- CalcA = (LargPav * LongPav) / ((LargPav + LargJoint) * (LongPav + LargJoint))
-
- End Function
- Function CalcB(LargPav, LongPav, LargJoint)
- 'Calcul du Pourcentage de Joints'
- On Error Resume Next
- CalcB = (((LargPav + LargJoint) * (LongPav + LargJoint)) - (LargPav * LongPav)) / ((LargPav + LargJoint) * (LongPav + LargJoint))
- End Function
- Function CalcC(LargPav, LongPav, LargJoint, Surf)
- 'Calcul de la surface de Pavés'
- On Error Resume Next
- CalcC = Surf * ((LargPav * LongPav) / ((LargPav + LargJoint) * (LongPav + LargJoint)))
- End Function
- Function CalcD(LargPav, LongPav, LargJoint, Surf)
- 'Calcul de la surface de Joints'
- On Error Resume Next
- CalcD = Surf * ((((LargPav + LargJoint) * (LongPav + LargJoint)) - (LargPav * LongPav)) / ((LargPav + LargJoint) * (LongPav + LargJoint)))
- End Function
- Function CalcE(Surf, EpLi)
- 'Calcul du Volume de Lit de Pose'
- On Error Resume Next
- CalcE = Surf * EpLi
- End Function
- Function CalcF(Surf, EpLi, DosageA)
- 'Calcul du Nombre de Sac de Ciment pour le Lit de Pose'
- On Error Resume Next
- CalcF = Format(Int((Surf * EpLi * DosageA) / 25), "# ##0" )
- End Function
- Function CalcG(LargPav, LongPav, LargJoint, Surf, HautPav)
- 'Calcul du Volume de Joints'
- On Error Resume Next
- CalcG = (HautPav * Surf * ((((LargPav + LargJoint) * (LongPav + LargJoint)) - (LargPav * LongPav)) / ((LargPav + LargJoint) * (LongPav + LargJoint))) / 100)
- End Function
- Function CalcH(LargPav, LongPav, LargJoint, Surf, HautPav, DosageB)
- 'Calcul du Nombre de Sac de Ciment pour les Joints'
- On Error Resume Next
- CalcH = Format(Int((DosageB * (HautPav * Surf * ((((LargPav + LargJoint) * (LongPav + LargJoint)) - (LargPav * LongPav)) / ((LargPav + LargJoint) * (LongPav + LargJoint))) / 100)) / 25), "# ##0" )
- End Function
|
|