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

Help with validation problem

I'm trying to get a validation of a text box to where if the information is not letters then it will display a error message. I know how to get the error message, but I dont dont know how to do a validation with letters. I know how to do it with number but not letters. Please help. Thanks.
Aug 1 '07 #1
6 924
fplesco
82
I'm trying to get a validation of a text box to where if the information is not letters then it will display a error message. I know how to get the error message, but I dont dont know how to do a validation with letters. I know how to do it with number but not letters. Please help. Thanks.
Hi dwd3773 -

You may try these codes below

Expand|Select|Wrap|Line Numbers
  1. Const strAlphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
  2. Private Sub cmdValidate_Click()
  3.     If InvalidTextboxInput = True Then
  4.         MsgBox "Textbox contains invalid character.", vbExclamation
  5.     Else
  6.         MsgBox "Valid textbox content.", vbInformation
  7.     End If
  8. End Sub
  9.  
  10. Private Function InvalidTextboxInput() As Boolean
  11.     For i = 1 To Len(TextBox1.Text)
  12.         If InStr(strAlphabet, UCase(Mid(TextBox1.Text, i, 1))) < 1 Then
  13.             InvalidTextboxInput = True
  14.             Exit For
  15.         End If
  16.     Next i
  17. End Function
  18.  
  19.  
Godspeed!
Aug 1 '07 #2
Killer42
8,435 Expert 8TB
I'm trying to get a validation of a text box ...
Quick question - what version of VB are you using?

Oh, and another question - have you considered using a masked edit control rather than a textbox? The masked edit control gives you more control over the format of the input.
Aug 1 '07 #3
No, I haven't thought of using one of those. I have strict guideline from my customer as to what they want, but I've never really validated letters only numbers. I 'm using Microsoft Visual Studio 2005.
Aug 1 '07 #4
Killer42
8,435 Expert 8TB
No, I haven't thought of using one of those. I have strict guideline from my customer as to what they want, but I've never really validated letters only numbers. I 'm using Microsoft Visual Studio 2005.
Fair enough.

You might as well go with the routine that fplesco provided. It looks as though it will work. One small change I would recommend, though. That is to have it accept the textbox (or just the text) as a parameter, so it's more widely applicable. Seems as though it would make a useful public function to add to your tool kit.
Aug 1 '07 #5
fplesco
82
Fair enough.

You might as well go with the routine that fplesco provided. It looks as though it will work. One small change I would recommend, though. That is to have it accept the textbox (or just the text) as a parameter, so it's more widely applicable. Seems as though it would make a useful public function to add to your tool kit.

[That is to have it accept the textbox (or just the text) as a parameter, so it's more widely applicable]

Good point Killer42. Thanks.
Aug 2 '07 #6
Killer42
8,435 Expert 8TB
Good point Killer42. Thanks.
I think it's a good general technique to try and write all one's routines so they're reusable. Though of course there are other considerations, such as performance.

(And of course, being so disorganised, I can never find them again later, anyway. But my intentions are good.)
Aug 3 '07 #7

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

Similar topics

1
by: Will Stuyvesant | last post by:
There seems to be no XML parser that can do validation in the Python Standard Libraries. And I am stuck with Python 2.1.1. until my web master upgrades (I use Python for CGI). I know pyXML has...
2
by: qsweetbee | last post by:
I have a form(fAddUsers) in my database. It is continue form for data entry. Some fields are required fields. Some are optional fields. There is 1 particular filed(TokenExpirationDate)on the form...
3
by: Navin | last post by:
Hello friends... On a single asp.net web page i have a single server-side form that contains a couple of user-controls. Each user control has its own functionality and contains server-side textbox...
5
by: Jim Brandley | last post by:
I have a required field with a client-side validator. It works as advertised until I try to add code to block double submits and replace the image on the submit button to give the users some...
3
by: john morales | last post by:
Hi guys, I have a problem and i know there must be a solution for this as it is such a basic common practice in asp.net development. Scenario: i have many webforms in a site, most with two...
2
by: msnews.microsoft.com | last post by:
Hi All, I m facing a problem. As u know asp.net vallidators did not work in non-microsoft browsers. So for that i m using Server Side Solution. But i don't understand how can i show the...
9
by: Bill Long | last post by:
I have a control that simply displays a list of links. Following one of the links doesn't post back or redirect to another page, it simply hides the current panel and shows the one you selected......
36
by: aljamala | last post by:
Hi, I keep getting this warning on a page, but I do not know what the problem is...does anyone have an idea about what could be wrong? line 88 column 7 - Warning: missing </formbefore <td> it...
2
by: vijaykk | last post by:
Hi @, I new to java and i am facing
4
by: AMBLY | last post by:
Hi Hope you can help me with this I run Access2000 on XP Form has 3 fields: cboSTATUS - which can be set via Limited value List A B or Complete. Default is set as A. cboTHIS - which can...
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...
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...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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.