Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default textbox character limits


Hey everyone...quick question....is there a way to limit a textbox on
form to only accept numbers? I don't want a user to be able to ente
any characters except 0-9..

--
dok11
-----------------------------------------------------------------------
dok112's Profile: http://www.excelforum.com/member.php...fo&userid=1058
View this thread: http://www.excelforum.com/showthread.php?threadid=38231

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default textbox character limits

One way... and I sure there is a more excel type way is

this will allow decimal point also


Private Sub textbox2_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If CheckBox2.Value = True Then
If KeyAscii 47 And KeyAscii < 58 Then ' 0 to 9
KeyAscii = KeyAscii
ElseIf KeyAscii = 8 Or KeyAscii = 13 Or KeyAscii = 46 Then ' backspace
and enter keys
KeyAscii = KeyAscii
Else
KeyAscii = 0
End If
End If
End Sub


  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11
Default textbox character limits

forgot the checkbox part as I added that to give option of number only or
alphas


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default textbox character limits

Hi Dok112,

See:

http://tinyurl.com/cp6oh

and

http://tinyurl.com/8rnvr


---
Regards,
Norman



"dok112" wrote in
message ...

Hey everyone...quick question....is there a way to limit a textbox on a
form to only accept numbers? I don't want a user to be able to enter
any characters except 0-9...


--
dok112
------------------------------------------------------------------------
dok112's Profile:
http://www.excelforum.com/member.php...o&userid=10581
View this thread: http://www.excelforum.com/showthread...hreadid=382315



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
Character limit in textbox Ashley Excel Worksheet Functions 1 September 10th 08 01:33 AM
Defining character limits Steelsilk Excel Worksheet Functions 2 May 15th 07 07:56 PM
HELP! I Lost The Ability To Advance From TextBox To TextBox With the ENTER Or The TAB Keys Minitman[_4_] Excel Programming 0 February 22nd 05 08:50 PM
Limits on Userform textbox radarguy Excel Programming 1 May 14th 04 02:19 PM
how to put tab character into textbox? Dirk[_2_] Excel Programming 7 February 11th 04 09:23 AM


All times are GMT +1. The time now is 04:11 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"