LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7
Default Text Box Data Validation

I have some text boxes on a form that I want the user to be limited to only
numeric entry. I found this code in an earlier thread:

Private Sub TextBox1_KeyDown(ByVal KeyCode As _
MSForms.ReturnInteger, ByVal Shift As Integer)
If Shift = 2 Then
If KeyCode = 86 Then KeyCode = 0
End If
End Sub


Private Sub TextBox1_KeyPress(ByVal KeyAscii _
As MSForms.ReturnInteger)
Select Case KeyAscii
Case 46
If InStr(TextBox1.Text, ".") 0 Then _
KeyAscii = 0
Case 48 To 57
Case Else
KeyAscii = 0
End Select
End Sub


This works great, but I need decimal entries to be allowed as well, and when
the user presses the "." key an error is returned. Since I'm fairly new at
this, and completely in the dark about limiting key entries, I need some help!


 
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
data validation for a single text entry MZ New Users to Excel 8 January 27th 10 09:57 PM
Data validation text size robnsd Excel Discussion (Misc queries) 1 April 20th 07 10:42 PM
Data Validation for text only formula Kimberly Excel Discussion (Misc queries) 4 November 9th 06 10:26 PM
Data Validation for text only Kimberly Excel Discussion (Misc queries) 6 November 8th 06 02:26 AM
Text message using data validation. Marcus Excel Discussion (Misc queries) 0 May 2nd 06 12:50 AM


All times are GMT +1. The time now is 09:50 AM.

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"