473,320 Members | 2,092 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,320 software developers and data experts.

how to restrict textbox from accepting chars. it should only accept numerics.

how to do that.

please if possible mail this solution to my mail id

mail id removed
Mar 19 '08 #1
1 1086
Expand|Select|Wrap|Line Numbers
  1. Private Sub Text1_KeyPress(KeyAscii As Integer)
  2. If (KeyAscii > 47 And KeyAscii < 58) Or KeyAscii = 46 Or KeyAscii = 8 Then
  3. KeyAscii = KeyAscii
  4. Else
  5. KeyAscii = 0
  6. End If
  7. End Sub
  8.  
KeyAscii "8" is for backspace
and keyascii "46" for decimal
Use them if reqd
Mar 19 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: JimO | last post by:
I teach HS computers and one of my kids has a web site with a textbox of info that the user can scroll down and read. The problem is that users can also enter text into it. Is there a way, or a...
2
by: anonieko | last post by:
This applies to javascript dynamic textbox onkey > > > Newsgroups: comp.lang.javascript From: Lasse Reichstein Nielsen <l...@hotpop.com> - Find messages by this author Date: Fri, 15 Jul 2005...
38
by: Keith | last post by:
I've been reading and looking on the internet - but I just can't fin this. Perhaps I'm approaching this the wrong way - code-wise I'm attempting to learn how "things" work in VBNET by creating...
2
by: Rain | last post by:
i have a method like this public void MethodName(byte data) { } and the textbox.text is the one suppying the argument to the method but my problem is its a string... how can i do this? any...
5
by: ameen.abdullah | last post by:
Hi Guys, I have a textbox in windows form that should only accept alphabets, numbers, spaces and underscore. If the textbox contains anyother character it should display a msg at the time of...
2
by: colleen1980 | last post by:
There is a textbox and a drop down. Once user enters any value in the textbox he has to select the option from drop down otherwise the cursor will not allow to move anywhere else accept the drop...
2
by: Vbbeginner07 | last post by:
Hi all Wonder if anyone can help me out to solve this: please find the code of textbox that accepts only characters and one textbox that accepts only numbers: (vb) textbox for accepting...
2
jkmyoung
by: jkmyoung | last post by:
I was trying to create an applet with a TextField that would only accept an integer, and ignore any other keystrokes. Eg, if a user typed in an 'f' into the field, the TextField should ignore it, and...
23
by: raashid bhatt | last post by:
what is restrict keyword used for? eg int *restrict p;
5
lotus18
by: lotus18 | last post by:
Hello World! I have a sample code here written in vb .net that restricts the textbox to accept only alpha, alphanumeric or numeric characters. Public Enum MyOption Alpha = 1 ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.