473,397 Members | 1,949 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,397 software developers and data experts.

validation query

A.J
Hi......
(Using vb.net, access as database and datareader to access the data)
Now i got few textboxes having attribute like name,age,phonenumber
etc.I want the txtname to contain only alpha(characters); likewise
txtage to contain number and txtphonenumber be in the format of
####-####-##(ex-9999-9999-99).*I searched the forum for this
validation
query and got the answer that this can be done using
char.Iscontrol/Isdigit...etc..*.I got the Concept(Like it takes a
unicode character 16-bit as argument and returns a boolean value) and
unable to figure out how to implement this or is there any other way of

implementing this concept.
As i am a newbie so please explain this concept in detail.
Thankx in advance!!!!

Nov 21 '05 #1
4 1394
what you do is override the OnKeyPress method and then set e.Handled =
True for cases that you wish to exclude.

a quick example to allow only numbers...

Public Class TextBox_NumericOnly : Inherits
System.Windows.Forms.TextBox
Protected Overrides Sub OnKeyPress(ByVal e As KeyPressEventArgs)
If (Char.IsNumber(e.KeyChar)=False) Then e.Handled=True
End Sub
End Class

you don't have to create your own control -- you can simply Override
the method, but since this is a common scenario, you may want to write
your own so that you can re-use it...

Nov 21 '05 #2
A.J


stand__sure wrote:
what you do is override the OnKeyPress method and then set e.Handled =
True for cases that you wish to exclude.

a quick example to allow only numbers...

Public Class TextBox_NumericOnly : Inherits
System.Windows.Forms.TextBox
Protected Overrides Sub OnKeyPress(ByVal e As KeyPressEventArgs)
If (Char.IsNumber(e.KeyChar)=False) Then e.Handled=True ' What this "handled" method suppose to do?? End Sub
End Class

you don't have to create your own control -- you can simply Override
the method, but since this is a common scenario, you may want to write
your own so that you can re-use it...


Nov 21 '05 #3
Hi,

Here is a link to a few free masked edit boxes.

http://www.codeproject.com/vb/net/cpflexmaskeditbox.asp
http://www.codeproject.com/useritems/MaskedTextBox.asp
Ken
----------------------
"A.J" <aj********@gmail.com> wrote in message
news:11*********************@o13g2000cwo.googlegro ups.com...
Hi......
(Using vb.net, access as database and datareader to access the data)
Now i got few textboxes having attribute like name,age,phonenumber
etc.I want the txtname to contain only alpha(characters); likewise
txtage to contain number and txtphonenumber be in the format of
####-####-##(ex-9999-9999-99).*I searched the forum for this
validation
query and got the answer that this can be done using
char.Iscontrol/Isdigit...etc..*.I got the Concept(Like it takes a
unicode character 16-bit as argument and returns a boolean value) and
unable to figure out how to implement this or is there any other way of

implementing this concept.
As i am a newbie so please explain this concept in detail.
Thankx in advance!!!!
Nov 21 '05 #4
it stops the character from being passed to the next event handler
(i.e. it is handled and no further processing is required).

you can also do field-level testing in the Validating event handler
(normally just to display a MessageBox describing the error and to
return focus to the control via e.Cancel = True)

Nov 21 '05 #5

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

Similar topics

21
by: Stefan Richter | last post by:
Hi, after coding for days on stupid form validations - Like: strings (min / max length), numbers(min / max value), money(min / max value), postcodes(min / max value), telefon numbers, email...
67
by: Scott Meyers | last post by:
I have a web site that, due to maintenance by several people, some of whom are fairly clueless about HTML and CSS, etc. (notably me), has gotten to the point where I'm pretty sure it's suffering...
2
by: Kostas | last post by:
Just a quick question on this issue. Assume a small set of fixed values for a field. For instance Field Gender, values: Male, Female, Unknown If I create a Combo Box with the above values, I...
1
by: Liz | last post by:
I have a page with several dropdownlists, several text boxes and several buttons which perform calculations. I need to validate one dropdownlist (not the whole page) with the click of one button. I...
3
by: Bob Alston | last post by:
I have a routine to copy data to new versions of my app via insert into sql statements. Unfortunately, due to evolution of my app, sometimes the new version has more restrictive editing than an...
1
by: RyanL | last post by:
All, I have an append query set up that pulls records off of one table and appends them to a linked table. However, when the query runs, it gives me an error message saying that the records could...
0
by: jasondavidcarr | last post by:
Hello all, I have a "comments" page that contains three sections; the article to be commented on is on top, followed by previous comments, and on the bottom a place to add new comments. It's a...
3
by: Harlequin | last post by:
I must start this posing by making the point that I am NOT a VB programmer and I'm something of a Newbie to MS Access. I can program in a number of languages (Java, Javascript, PERL,PHP and TCL) but...
2
by: Sudhakar | last post by:
A) validating username in php as part of a registration form a user fills there desired username and this is stored in a mysql. there are certain conditions for the username. a) the username...
1
by: MLH | last post by:
Anyone remember if A97 append query failure would ever report data breaking validation rule when such was not the case. I have an old SQL statement - several years old now. I've encountered a case...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.