473,399 Members | 4,177 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

TextBox numerical values

Hi all,

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

many thanks

rodger

Nov 20 '05 #1
9 2078
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.
Nov 20 '05 #2
* "Mr Utkal Ranjan Pradhan" <ut*****@hotmail.com> scripsit:
On Text Box Key Press event procedure write

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


That's not VB.NET code.

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

<http://www.plig.net/nnq/nquote.html>
Nov 20 '05 #3
* rodger <pa*@myisland.spam> scripsit:
how do I set a Textbox to only accept numerical values in vb .net


Use a NumericUpDown control instead.

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

<http://www.plig.net/nnq/nquote.html>
Nov 20 '05 #4
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> schrieb
* "Mr Utkal Ranjan Pradhan" <ut*****@hotmail.com> scripsit:
On Text Box Key Press event procedure write

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


That's not VB.NET code.


It is newsclient.net code. ;-)
--
Armin

Nov 20 '05 #5
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?
Herfried K. Wagner [MVP] wrote:
* rodger <pa*@myisland.spam> scripsit:
how do I set a Textbox to only accept numerical values in vb .net

Use a NumericUpDown control instead.


Nov 20 '05 #6
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?
Herfried K. Wagner [MVP] wrote:
* rodger <pa*@myisland.spam> scripsit:
how do I set a Textbox to only accept numerical values in vb .net

Use a NumericUpDown control instead.

Nov 20 '05 #7
* rodger <pa*@myisland.spam> scripsit:
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>
Nov 20 '05 #8
Cor
Hi Herfried,

Is that not in the WillBe version?

:-)))

Cor
Nov 20 '05 #9
Hello, rodger:

You may find useful the sample for the TextChanged event for the textbox:
http://msdn.microsoft.com/library/de...angedtopic.asp

Regards.
"rodger" <pa*@myisland.spam> escribió en el mensaje news:Oz*************@tk2msftngp13.phx.gbl...
| Hi all,
|
| how do I set a Textbox to only accept numerical values in vb .net
|
| many thanks
|
| rodger
|
Nov 20 '05 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: rodger | last post by:
Hi all, how do I set a Textbox to only accept numerical values in vb .net many thanks rodger
2
by: Martin McCormick | last post by:
Most of the C programming I write manipulates strings so I haven't had much experience with numerical functions and passing variables in and out which brings me to a laughably simple problem that I...
2
by: RobRich | last post by:
I'm trying to figure out the best way to accomplish a task. I need to calculate the numerical values from about 300+ textboxes. Basiclly I have an application that users input checks and credit...
2
by: Abra | last post by:
Hi, I would like to allow only some pre-defined characters to be typed in a TextBox (for example only integer numerical, or float numerical, or only a set of letters and so on). How can this be...
16
by: Martin Jørgensen | last post by:
Hi, I've made a program from numerical recipes. Looks like I'm not allowed to distribute the source code from numerical recipes but it shouldn't even be necessary to do that. My problem is...
6
by: Avi G | last post by:
Hi, what is the code to limit a textbox that will accept only text and not number private void button1_Click(object sender, EventArgs e) { if (textBox1.Text = "numbers") { // do something }
2
by: jediknight | last post by:
Hi, I have a listview which has columns of text and columns of numerical data. I need to be able to sort these columns into ascending/desending order whenever the user clicks on the column...
10
by: Parachute | last post by:
Using Borland Builder 6, I get numerical overflow when running a small programme without CodeGuard ("exp: OVERFLOW error"). The programme does not give any error messages when CodeGuard is...
7
by: weg22 | last post by:
Hi all, I need to impose maximum and minimum numerical limits on a textbox. I'd prefer not to code these in (since I have many textboxes and the limits on each are different) and was wondering...
3
by: sannihith | last post by:
how do I set a Textbox to only accept numerical values in vb .net
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.