Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
In a textbox of my userform only the comma and digits are allowed. But, the
user must not be able to make long entry: such as 1,65647. Only two digits AFTER the comma are allowed. Digits on the third position must be deleted. Can someone help? |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
With Me.TextBox1 Select Case KeyAscii Case 44: ' comma If Len(.Text) - Len(Replace(.Text, ",", "")) = 1 Then MsgBox "Too many commas" KeyAscii = 0 End If Case 48 To 57: '0-9 If InStr(.Text, ",") 0 Then If InStr(.Text, ",") = Len(.Text) - 2 Then MsgBox "Only 2 dec places" KeyAscii = 0 End If End If End Select End With End Sub -- HTH Bob Phillips (replace xxxx in the email address with gmail if mailing direct) "Gert-Jan" wrote in message ... In a textbox of my userform only the comma and digits are allowed. But, the user must not be able to make long entry: such as 1,65647. Only two digits AFTER the comma are allowed. Digits on the third position must be deleted. Can someone help? |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks, this works great!!
"Bob Phillips" schreef in bericht ... Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) With Me.TextBox1 Select Case KeyAscii Case 44: ' comma If Len(.Text) - Len(Replace(.Text, ",", "")) = 1 Then MsgBox "Too many commas" KeyAscii = 0 End If Case 48 To 57: '0-9 If InStr(.Text, ",") 0 Then If InStr(.Text, ",") = Len(.Text) - 2 Then MsgBox "Only 2 dec places" KeyAscii = 0 End If End If End Select End With End Sub -- HTH Bob Phillips (replace xxxx in the email address with gmail if mailing direct) "Gert-Jan" wrote in message ... In a textbox of my userform only the comma and digits are allowed. But, the user must not be able to make long entry: such as 1,65647. Only two digits AFTER the comma are allowed. Digits on the third position must be deleted. Can someone help? |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Data validation within a userform | Excel Programming | |||
userform validation? | Excel Programming | |||
Userform with validation... | Excel Programming | |||
UserForm Date Validation | Excel Programming | |||
Userform Validation | Excel Programming |