
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