TextBox numerical values

  • Thread starter Thread starter rodger
  • Start date Start date
R

rodger

Hi all,

how do I set a Textbox to only accept numerical values in vb .net

many thanks

rodger
 
On Text Box Key Press event procedure write

if Not Instr(1,"1234567890",chr$(KeyAscii,0) > 0 or KeyAscii = 8) then
KeyAscii=0

Mr Utkal Ranjan, New Delhi.
 
I am not sure the NumericUpDown list is what I am looking for,

as what I have is a simple Textbox, and I just want to ensure that only
numbers are entered, (later they are picked up by a formula)

on further research i have found
TextBox1.Numeric = true

for VB

so maybe there is an equivalent for VB .net?
 
I am not sure the NumericUpDown list is what I am looking for,

as what I have is a simple Textbox, and I just want to ensure that only
numbers are entered, (later they are picked up by a formula)

on further research i have found
TextBox1.Numeric = true

for VB

so maybe there is an equivalent for VB .net?
 
* rodger said:
I am not sure the NumericUpDown list is what I am looking for,

as what I have is a simple Textbox, and I just want to ensure that
only numbers are entered, (later they are picked up by a formula)

I would not prvent the user from entering non-numeric characters.
Instead I would add validation code to its 'Validating' event handler
and use an ErrorProvider to make the user aware of wrong input.

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

<http://www.plig.net/nnq/nquote.html>
 
Back
Top