cool_brainmint
05-06-2004, 07:08 AM
we only need to allow to numbers to be entered in a textbox.. i mean if you have typed 2 digit numbers already, the third digit to be entered will cause a beep..
how to limit the number of digits in a textbox?cool_brainmint 05-06-2004, 07:08 AM we only need to allow to numbers to be entered in a textbox.. i mean if you have typed 2 digit numbers already, the third digit to be entered will cause a beep.. Jigo 05-06-2004, 07:12 AM Set the textbox MaxLength property to 2. IGBP 05-06-2004, 07:22 AM If you do not have code to allow only numbers .... search this board. Hundreds of examples. Also in the tutors corner there are examples and (I believe) an ActiveX control that is a true only numbers textbox. Check those out. miwaypro 05-06-2004, 07:24 AM how to limit the user input from 0 to 9 and dot only?? :confused: bluelotus 05-06-2004, 07:27 AM we only need to allow to numbers to be entered in a textbox.. i mean if you have typed 2 digit numbers already, the third digit to be entered will cause a beep.. set textboxname.maxlength = 2 in form_load event eg: Private Sub Form_Load() Text1.MaxLength = 2 End Sub Jigo 05-06-2004, 07:45 AM how to limit the user input from 0 to 9 and dot only?? :confused: Check this out: http://www.xtremevbtalk.com/showthread.php?t=162583 loquin 05-06-2004, 09:28 AM Here's a simple number check routine that can be called from your keypress routine: Public Function NumberCheck(Keyasc As Integer) Const ValidCh = "0123456789.-" ' Note: if entry needed for exponential numbers (3.56E04) add "eE" to ValidCH ' To allow positive numbers only, remove '-' from ValidCh If Keyasc >= 32 And InStr(1, ValidCh, Chr(Keyasc)) = 0 Then ' Ascii codes < 32 not affected NumberCheck = 0 Beep Else If Keyasc = 13 Then ' treat <Enter> like a <Tab> NumberCheck = 0 SendKeys "{Tab}" Else NumberCheck = Keyasc End If End If End Function to use: Sub txtNumbers_KeyPress(KeyAscii as Integer) KeyAscii = NumberCheck(KeyAscii) End Sub miwaypro 05-06-2004, 08:28 PM thks |
EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum