HELP Formatting TextBox for whole numbers 
Author Message
 HELP Formatting TextBox for whole numbers

Can anyone tell me how to format a textbox to accept whole numbers only.
I've tried various ways to do this according to the manual, but maybe I'm
putting it it the wrong place. I've tried various places but the resulting
numeric answer in the textbox always gives me an answer with about seven
decimal places. I want it to show only the whole number.
I'm using VB4 and am only NEW to this but find the code sometimes more than
BASIC.
Thanks.
Lucas de Jong



Tue, 14 Dec 1999 03:00:00 GMT  
 HELP Formatting TextBox for whole numbers

If you want to validate what the user types in, trap the key strokes in the
KeyPress event of the TextBox control.

For example, if you have a TextBox named Text1 you'd use the following code
to allow only numbers 0 - 9:

Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii < Asc("0") Or KeyAscii > Asc("9") Then
    KeyAscii = 0
End If
End Sub

Regards,

--
Keith Benedict
Software Engineer
Triad Systems

*** My reply email address is mangled to cut down on the

US Code Title 47, Sec.227(a)(2)(B), a computer / modem / printer
meets the definition of a telephone fax machine.  Sec. 227
(b)(1)(C), it is unlawful to send any unsolicited adverti{*filter*}t
to such equipment.  Sec.227(b)(3)(C), a violation of the
aforementioned Section is punishable by action to recover actual
monetary loss, or $500, whichever is greater, for each violation.



Quote:
> Can anyone tell me how to format a textbox to accept whole numbers only.
> I've tried various ways to do this according to the manual, but maybe I'm
> putting it it the wrong place. I've tried various places but the
resulting
> numeric answer in the textbox always gives me an answer with about seven
> decimal places. I want it to show only the whole number.
> I'm using VB4 and am only NEW to this but find the code sometimes more
than
> BASIC.
> Thanks.
> Lucas de Jong




Tue, 14 Dec 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Force Textbox to accept only whole numbers

2. from Microsoft format Number to IEE format Number

3. Format phone number inside textbox control

4. number formatting in a textbox

5. formatting numbers in textboxes

6. Guarantee Number Formatting in a Textbox?

7. Formatting Numbers in a Textbox/Richtextbox

8. Format Numbers in VB Textbox

9. formatting numbers in textboxes

10. Validate and Format Currency Numbers in Textbox

11. set the focus on the whole text in a textbox

12. Convert decimals to whole numbers

 

 
Powered by phpBB® Forum Software