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

Validate Textbox

Hi All,


I have a textbox that should be validated to enter letters only. However, if the users enter number it should be given error message. This application is windows application.


Any volunteer to help me to solve this particularly problem.


I’m looking forward to answering this post.


Thanks & Regards,

Aisha
May 7 '07 #1
10 1226
gomzi
304 100+
Hi All,


I have a textbox that should be validated to enter letters only. However, if the users enter number it should be given error message. This application is windows application.


Any volunteer to help me to solve this particularly problem.


I’m looking forward to answering this post.


Thanks & Regards,


Aisha
try out -> regex.ismatch(yourstring,"^([a-z])*$")
May 7 '07 #2
try out -> regex.ismatch(yourstring,"^([a-z])*$")

Where should I place this code?




Thanks & Regards,

Aisha
May 7 '07 #3
gomzi
304 100+
Where should I place this code?




Thanks & Regards,

Aisha
inside the event of your form submit button.
May 7 '07 #4
What is the data type of regex because I have to declare?



Thanks & Regards,

Aisha
May 7 '07 #5
gomzi
304 100+
What is the data type of regex because I have to declare?



Thanks & Regards,

Aisha
There is no need for declaring it.
You will be using its static method "IsMatch()"
May 7 '07 #6
I got error that telling me regex not declared. I placed the code in save button as following:


regex.ismatch(txtemployeeName,"^([a-z])*$")


Should I need to important any ting?



Thanks & Regards,

Aisha
May 7 '07 #7
gomzi
304 100+
I got error that telling me regex not declared. I placed the code in save button as following:


regex.ismatch(txtemployeeName,"^([a-z])*$")


Should I need to important any ting?



Thanks & Regards,

Aisha
try importing system.text and system.text.regularexpressions
May 7 '07 #8
Hi Aisha,

The Most simple way of doing it is to trap the ASCII value in the hey press event of the textbox and validate the character.

The Following is asample code for not allowing any values except a-z and A-Z

Private Sub TextBoxKeyPress(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) _
Handles TextBoxName.KeyPress
Select Case Asc(e.KeyChar)
Case 97 To 122, 65 To 90
Case Else
e.Handled = True
End Select
End Sub

Hope this will solve your purpose.

Regards,
Naveen
May 7 '07 #9
Hi Aisha,

48-57 is the ASCII range for 0-9

Instead of e.Handled, give the message in the message box.

Regards,
Naveen
May 7 '07 #10
Hi Naveen


First, I would like to thank you for helping me to solve this problem a lot.

Case 97 To 122, 65 To 90

Could explain for me this line please?



You supporting is appreciated


Thanks & Regards,

Aisha
.
May 8 '07 #11

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

Similar topics

3
by: rodger | last post by:
How do i validate text box entry, in VB. net In the event that user does not make a text entry, simply pop-up a warning, thanks rodger
5
by: Jeff Evans | last post by:
I have a custom composite control which has a validator for a textbox. The validator and textbox are declared in the class and created in the CreateChildControls() method Here is the code for the...
11
by: wolf | last post by:
There are three webcontrol on my asp.net form: a TextBox, a submit button and a RegularExpressionValidator. And I had set ControlToValidate property of the RegularExpressionValidator to the...
2
by: Peter | last post by:
I need to validate 4 fields on ASP.NET web page Starting Date __/__/____ Starting Time __:__ Ending Date __/__/____ Ending Time __:__ Staring Date + StartingTime...
7
by: Rich | last post by:
Hello, I have 10 textboxes on a form. I would like to validate text-data entry on each textbox. I was looking for a Form_Current event or Form_Change event but did not recognize any such...
9
by: B-Dog | last post by:
I have a form that has about 10 text boxes on it, they all have to be filled out before submitting is there a quick way to make sure that none are null or do I have to call out each textbox? Say...
11
by: jjbutera | last post by:
I know how to use the ErrorProvider in my winforms..or do I? I validate the values and set the ErrorProvider in the validating event. If not valid, I set e.Cancel = True. I clear the ErrorProvider...
4
by: Michel Posseth [MCP] | last post by:
I have a problem with the date time picker validate event wich i believe is a bug How to reproduce : throw on a form a date time picker control and a textbox control select the validating...
3
by: Jeff Jarrell | last post by:
I have one textbox on a form. Nothing else. The validate event doesn't fire. Drop another textbox on the form and the validate event fires. Set tabstop = false on the 2nd text box and the...
1
by: JFKJr | last post by:
Hello everyone, the following Access VBA code opens an excel file and creates textboxes in a given range of cells dynamically. The code attaches "MouseUP" and "Exit" events to the textboxes (using...
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
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: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
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: 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
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.