Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I'm glad you liked it. Since you are planning on using it for your basic
number validation routine, I thought you might like its companion routine for proofing digits only. I have included the code for it after my signature. There are no limits to set within the code for this version as the TextBox itself has a MaxLength property where you can limit the total number of characters typed in. I used the same TextBox name (Intrate) in this routine as I did for the floating point one... the TextBox names are all specified in With statements, so changing them to match your current TextBox name will be easy enough to do. Oh, if you want to allow your user to be able to type in a leading plus or minus sign, change this If-Then statement (in the Change event procedure)... If .Text Like "*[!0-9]*" Then to this instead... If .Text Like "*[!0-9+-]*" Or .Text Like "?*[+-]*" Then Rick 'For typing digits only in the TextBox '===================================== Dim LastPosition As Long Private Sub Intrate_Change() Static LastText As String Static SecondTime As Boolean If Not SecondTime Then With Intrate If .Text Like "*[!0-9]*" Then Beep SecondTime = True .Text = LastText .SelStart = LastPosition Else LastText = .Text End If End With End If SecondTime = False End Sub Private Sub Intrate_MouseDown(ByVal Button As Integer, _ ByVal Shift As Integer, _ ByVal X As Single, _ ByVal Y As Single) With Intrate LastPosition = .SelStart 'Place any other MouseDown event code here End With End Sub Private Sub Intrate_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger) With Intrate LastPosition = .SelStart 'Place any other KeyPress checking code here End With End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Decimal Points | New Users to Excel | |||
How can I convert decimal commas to decimal points? | Excel Discussion (Misc queries) | |||
Aligning Decimal Points with non-numeric data | Excel Discussion (Misc queries) | |||
Decimal Points | Excel Worksheet Functions | |||
Decimal points not needed | Excel Worksheet Functions |