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

How do I get a textbox to only allow numbers

Thanks in advance

Greg


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 110
Default Textbox format

Hi Greg
You could use the Keypress event from your textbox and then using the
KeyAscii, check each input allowing only numbers.
HTH
Cordially
Pascal

"Greg B" a écrit dans le message de
...
How do I get a textbox to only allow numbers

Thanks in advance

Greg




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Textbox format

Sorry to be a pain how do I do that?

Thanks again

Greg



  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Textbox format

Greg,

This allows numbers, - and .. Adjust to suit

Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case 48 To 57 'Nos 0 - 9
Exit Sub
Case 45, 46 ' - and .
Exit Sub
Case Else
Application.EnableEvents = False
KeyAscii = 0
Application.EnableEvents = True
Beep
End Select


End Sub



--

HTH

RP
(remove nothere from the email address if mailing direct)


"Greg B" wrote in message
...
Sorry to be a pain how do I do that?

Thanks again

Greg





  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default Textbox format

thanks Bob for your help

Greg



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
TextBox format? Pas Excel Discussion (Misc queries) 5 April 25th 10 11:13 PM
TextBox format? AOU Excel Discussion (Misc queries) 4 June 12th 07 11:24 PM
TextBox Format grahammal Excel Discussion (Misc queries) 3 March 29th 06 01:35 PM
textbox - format for dates (mm/dd/yyy) barrfly[_2_] Excel Programming 1 December 22nd 03 08:19 PM
Format Textbox as % Todd Huttenstine[_2_] Excel Programming 2 December 15th 03 12:07 AM


All times are GMT +1. The time now is 03:02 AM.

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

About Us

"It's about Microsoft Excel"