Bonjour le forum,
j'ai créé un userform dans lequel j'aimerai calculer une surface si on introduis la largeur et la longueur.
J'ai donc créé un userform (m²) avec (entre autre) 3 textbox (Lgt, Larg et Surf) et j'ai repris un code trouvé sur le net que j'ai essayé d'adapter.
Apparemment je m'y prend comme une bille...
Voici le code :
Private Sub Lgt_AfterUpdate()
If m².Lgt.Value = "" Or m².Larg.Value = "" Then Exit Sub
m².Surf = CDec(m².Lgt) * CDec(m².Larg)
End Sub
Private Sub Larg_AfterUpdate()
If m².Lgt.Value = "" Or m².Larg.Value = "" Then Exit Sub
m².Surf = CDec(m².Lgt) * CDec(m².Larg)
End Sub
Private Sub Lgt_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'TRANSFORMER LE POINT PAR UNE VIRGULE
If KeyAscii = 46 Then KeyAscii = 44
If InStr("1234567890,-", Chr(KeyAscii)) = 0 Then KeyAscii = 0
End Sub
Private Sub Larg_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
'TRANSFORMER LE POINT PAR UNE VIRGULE
If KeyAscii = 46 Then KeyAscii = 44
If InStr("1234567890,-", Chr(KeyAscii)) = 0 Then KeyAscii = 0
End Sub
Private Sub Surf_Change()
m².Surf = Format(m².Surf.Value, "# ##0.00")
End Sub
Lorsque je rentre une valeur dans Lgt ou Larg j'ai une erreur :
Pourriez-vous m'expliquer ce que je fait mal svp