Private Sub cb_ajouter_Click()
If Me.txtnumpiece = "" Then
MsgBox "saisir un no de pièce"
Me.txtnumpiece.SetFocus
Exit Sub
End If
Set f = Sheets("inventaire")
ligne = f.[A65000].End(xlUp).Row + 1
f.Cells(ligne, 1) = Me.txtnumpiece
f.Cells(ligne, 2) = Me.txtdescription
f.Cells(ligne, 3) = Me.txtemplacement
If IsNumeric(Me.txtprix) Then f.Cells(ligne, 5) = CDbl(Me.txtprix)
If IsNumeric(Me.txtquantité) Then f.Cells(ligne, 4) = CDbl(Me.txtquantité)
raz
Me.txtnumpiece.SetFocus
End Sub
Sub raz()
Dim c As Control
For Each c In Me.Controls
Select Case TypeName(c)
Case "TextBox"
c.Value = ""
Case "CheckBox"
c.Value = False
Case "ListBox", "ComboBox"
c.ListIndex = -1
End Select
Next c
Me.txtnumpiece.SetFocus
End Sub
Private Sub cb_annuler_Click()
raz
End Sub
Private Sub txtprix_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If InStr("0123456789,", Chr(KeyAscii)) = 0 Then
KeyAscii = 0
Beep
End If
End Sub
Private Sub txtquantité_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If InStr("0123456789,", Chr(KeyAscii)) = 0 Then
KeyAscii = 0
Beep
End If
End Sub