Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > text field validation


Reply
 
Thread Tools Display Modes
  #1  
Old 12-31-2003, 12:44 AM
fastLearner fastLearner is offline
Newcomer
 
Join Date: Sep 2003
Posts: 5
Default text field validation


i have a question about validation in VBscript.
can anyone help me how to make a code that would only validate the string if it contains only letters A-Z if it contains anything else like "#" "@" $" it doesnt get validated.
I know how to validate for numbers using Isnumeric but this is something beyond my knowledge. Please help.
Reply With Quote
  #2  
Old 12-31-2003, 01:32 AM
rajeeshun rajeeshun is offline
Senior Contributor
 
Join Date: Oct 2002
Location: Dubai & Srilanka (Jaffna)
Posts: 1,151
Default

Quote:
Originally Posted by fastLearner
i have a question about validation in VBscript.
can anyone help me how to make a code that would only validate the string if it contains only letters A-Z if it contains anything else like "#" "@" $" it doesnt get validated.
I know how to validate for numbers using Isnumeric but this is something beyond my knowledge. Please help.



Easy way is Find the Keyascii value for the special characters. You cud find this by putting a break point on Keypress event. (I think it is coming around 33 to 37- But not sure)
Then you can validate as usual (Saying keyascii=0)
Reply With Quote
  #3  
Old 12-31-2003, 04:23 AM
thingimijig thingimijig is offline
Senior Contributor

* Expert *
 
Join Date: Jul 2003
Posts: 1,300
Default

you will need to loop through each char to check if its a letter or any other char.

Code:
Dim i As Integer, counter As Integer For i = 1 To Len(Text1.Text) Select Case Asc(Mid$(Text1.Text, i, 1)) Case 65 To 90, 97 To 122 'doesnt count if letters, uppercase or lowercase Case Else counter = counter + 1 End Select Next i If counter = 0 Then MsgBox "Validate" Else MsgBox "Not valid" End If

thingimijig.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Bullettin problem pckm_123 Word, PowerPoint, Outlook, and Other Office Products 1 12-03-2003 06:59 AM
Text Box Validation Query trigg23 General 3 11-26-2003 03:51 PM
Check text field and allow user input poli13 General 2 11-25-2003 09:09 AM
Alternative to Multiline Text field input grizlE General 18 07-23-2003 06:56 AM
Wraping text around an image? Serevinus Web Programming 7 06-20-2002 01:46 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->