snb
Verenigingslid
- Lid geworden
- 12 jun 2008
- Berichten
- 19.725
Naar aanleiding van deze vraag:http://www.helpmij.nl/forum/showthread.php/923263-Alleen-bedragen-in-textbox-toestaan
Maak een keuze uit een van de _Keypress gebeurtenissen
Maak een keuze uit een van de _Keypress gebeurtenissen
Code:
Private Sub TextBox1_BeforeDropOrPaste(ByVal Cancel As MSForms.ReturnBoolean, ByVal Action As MSForms.fmAction, ByVal Data As MSForms.DataObject, ByVal X As Single, ByVal Y As Single, ByVal Effect As MSForms.ReturnEffect, ByVal Shift As Integer)
If Action = 2 Then Cancel = True
End Sub
' Alleen cijfers
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii < 48 Or KeyAscii > 58 Then KeyAscii = 0
End Sub
' Alleen cijfers en punt
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If (KeyAscii < 48 And KeyAscii <> 46) Or KeyAscii > 58 Then KeyAscii = 0
End Sub
' Alleen cijfers en komma
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If (KeyAscii < 48 And KeyAscii <> 44) Or KeyAscii > 58 Then KeyAscii = 0
End Sub
' Alleen cijfers en negatief teken op de eerste plaats
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii < 48 And (KeyAscii <> 44 And Len(TextBox1) <> 0) Or KeyAscii > 58 Then KeyAscii = 0
End Sub