Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,202
Default I am getting duplicate decimal points on numeric validation

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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Decimal Points Jim Wyns[_2_] New Users to Excel 2 July 21st 08 03:41 PM
How can I convert decimal commas to decimal points? Peteylepieu Excel Discussion (Misc queries) 1 October 2nd 07 10:18 PM
Aligning Decimal Points with non-numeric data notloiseweiss Excel Discussion (Misc queries) 3 November 11th 05 10:17 PM
Decimal Points Leanne Excel Worksheet Functions 1 June 28th 05 02:30 AM
Decimal points not needed Paul K. Excel Worksheet Functions 1 June 3rd 05 02:51 PM


All times are GMT +1. The time now is 04:59 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"