#1   Report Post  
Greg B
 
Posts: n/a
Default Digits in textbox's

Hi all just wondering how I can get someone only to type number in a certain
textbox?

Thanks in advance

Greg


  #2   Report Post  
Vasant Nanavati
 
Posts: n/a
Default

Is this a TextBox on a UserForm?

Somewhat crude, but try the following:

Private Sub TextBox1_Change()
If Not IsNumeric(TextBox1.Text) Then _
SendKeys "{BACKSPACE}"
End Sub

--

Vasant




"Greg B" wrote in message
...
Hi all just wondering how I can get someone only to type number in a
certain
textbox?

Thanks in advance

Greg




  #3   Report Post  
Greg B
 
Posts: n/a
Default

Thank you for that

Greg
"Vasant Nanavati" <vasantn AT aol DOT com wrote in message
...
Is this a TextBox on a UserForm?

Somewhat crude, but try the following:

Private Sub TextBox1_Change()
If Not IsNumeric(TextBox1.Text) Then _
SendKeys "{BACKSPACE}"
End Sub

--

Vasant




"Greg B" wrote in message
...
Hi all just wondering how I can get someone only to type number in a
certain
textbox?

Thanks in advance

Greg






  #4   Report Post  
Chip Pearson
 
Posts: n/a
Default

Better than SendKeys, use the KeyPress event.


Private Sub TextBox1_KeyPress(ByVal KeyAscii As
MSForms.ReturnInteger)
If KeyAscii < 48 Or KeyAscii 57 Then
KeyAscii = 0
End If
End Sub



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"Vasant Nanavati" <vasantn AT aol DOT com wrote in message
...
Is this a TextBox on a UserForm?

Somewhat crude, but try the following:

Private Sub TextBox1_Change()
If Not IsNumeric(TextBox1.Text) Then _
SendKeys "{BACKSPACE}"
End Sub

--

Vasant




"Greg B" wrote in message
...
Hi all just wondering how I can get someone only to type
number in a certain
textbox?

Thanks in advance

Greg






  #5   Report Post  
Vasant Nanavati
 
Posts: n/a
Default

Hi Chip:

I knew there was a better solution but just couldn't get my brain to come up
with it <g.

Regards,

Vasant

"Chip Pearson" wrote in message
...
Better than SendKeys, use the KeyPress event.


Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii < 48 Or KeyAscii 57 Then
KeyAscii = 0
End If
End Sub



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"Vasant Nanavati" <vasantn AT aol DOT com wrote in message
...
Is this a TextBox on a UserForm?

Somewhat crude, but try the following:

Private Sub TextBox1_Change()
If Not IsNumeric(TextBox1.Text) Then _
SendKeys "{BACKSPACE}"
End Sub

--

Vasant




"Greg B" wrote in message
...
Hi all just wondering how I can get someone only to type number in a
certain
textbox?

Thanks in advance

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
Lookup the 1st 5 digits Deeds Excel Worksheet Functions 4 September 1st 05 04:38 PM
Mod 10 & 11 Pablo Excel Worksheet Functions 13 August 10th 05 11:39 AM
Help - Any number longer than 12 digits turns to scientific and ro LMH_VT Excel Discussion (Misc queries) 3 July 17th 05 03:58 PM
Concatenate function - keeping "displayed" extra digits EricKei Excel Discussion (Misc queries) 3 June 15th 05 10:16 PM
Least number of digits in Y-axis labels Charley Kyd Charts and Charting in Excel 9 February 6th 05 03:03 PM


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

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"