Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 54
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  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Digits in textbox's

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  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 54
Default Digits in textbox's

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  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Digits in textbox's

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  
Posted to microsoft.public.excel.misc,microsoft.public.excel.programming
external usenet poster
 
Posts: 1,080
Default Digits in textbox's

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
VBA write macro change column with 3 number digits to 4 digits the James C[_2_] Excel Discussion (Misc queries) 3 January 25th 10 03:12 PM
How to customize number to 10 digits including 2 digits after deci Carina Excel Worksheet Functions 3 September 20th 07 02:50 AM
Digits in textbox's Greg B Excel Discussion (Misc queries) 4 September 4th 05 06:23 PM
Textbox's truncated once printed (Excel 2000) Robert Pemberton Excel Discussion (Misc queries) 2 January 14th 05 02:19 AM
Textbox's and Dates the usual conflict Marcus Walker Excel Programming 1 October 19th 04 02:52 PM


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