LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default Visual Basic for Excel

Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
Select Case KeyAscii
Case 45 'negative
If Len(Trim(TextBox1.Text)) 1 Then
Beep
KeyAscii = 0
End If
Case 46 'period
If InStr(TextBox1.Text, ".") 0 Then
Beep
KeyAscii = 0
End If
Case 48 To 57 'numbers
If InStr(TextBox1.Text, ".") 0 Then
If Len(TextBox1.Text) InStr(TextBox1.Text, ".") + 1 Then
Beep
KeyAscii = 0
End If
End If
Case Else 'Discard anything else
Beep
KeyAscii = 0
End Select
End Sub



--
HTH

Bob Phillips

(replace somewhere in email address with gmail if mailing direct)

"Amit" wrote in message
...
I have made a user form consisting of various Text Boxes. Can I control

the
entry type in the Box? eg I would like that only integers be entered in

the
Text Box.



 
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
Is Visual Basic the same as Visual Studio 2008? Mike Stewart Excel Worksheet Functions 5 January 11th 09 04:58 PM
Make visual basic truely visual! GraphicalGuy Excel Programming 0 October 20th 06 05:53 PM
Can I run Visual Basic procedure using Excel Visual Basic editor? john.jacobs71[_2_] Excel Programming 3 December 26th 05 02:22 PM
changing the visual basic in office 2003 to visual studio net bigdaddy3 Excel Discussion (Misc queries) 1 September 13th 05 10:57 AM
Excel/Visual Basic MikeS[_2_] Excel Programming 0 October 12th 04 03:07 PM


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