code needed for serial number

I need code for registration of a prog. the code must match the following:

         A = any letter from a to z
         1 = any number from 1 to 0

Code needs to match the following format "AAA1A11AA1A1"

If code entered,does not match the format of  
"AAA1A11AA1A1" then exit setup
hjaycoxAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

RanaHossainCommented:
Public Function isValid() as boolean
     dim regEX as RegExp
     set regEX = new RegExp
     with regEX
          .Pattern = "^[a-z]{3}\d[a-z]\d{2}[a-z]{2}\d[a-z]\d$"
          .IgnoreCase = True
          .Global = True
          isValid = .Test(stringV)
     end with
     set regEX = nothing
end function

msgbox isValid("AAA1A11AA1A1a")

wrote and tested as vbs.. but should work in vb
0
RanaHossainCommented:
sorry, small mistake ---------

Public Function isValid(byVal stringV as string) as boolean
     dim regEX as RegExp
     set regEX = new RegExp
     with regEX
          .Pattern = "^[a-z]{3}\d[a-z]\d{2}[a-z]{2}\d[a-z]\d$"
          .IgnoreCase = True
          .Global = True
          isValid = .Test(stringV)
     end with
     set regEX = nothing
end function

msgbox isValid("AAA1A11AA1A1a")
0
BandyCommented:
Theoretically, yes, but I don't believe that Vb comes with the RegExp object, I think you need to download something to make VB support RegExp...

VB's "LIKE" function is not as powerful as full RegExp support, but you can do it...


    'Note: Because of the "Ucase" statement, this
    'function is NOT case sensitive.  If you require
    'case sensitive, remove the "UCASE" first.
    'Note: "[A-Z]" matches any character
    '      "#"     matches any digit
    'Just combine the two into the pattern you want to match.

Public Function isValid(ByVal str As String) As Boolean
    isValid = (UCase(str) Like "[A-Z][A-Z][A-Z]#[A-Z]##[A-Z][A-Z]#[A-Z]#")
End Function


0
RanaHossainCommented:
agreed... you need regular expression library.but the advantage is - as you said, it is very powerful.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
BandyCommented:
Seeing as everybody agrees regular expressions are more powerful, If you decide you want the Rexular Expression Library, you should be able to download it here:

http://msdn.microsoft.com/downloads/default.asp?url=/downloads/sample.asp?url=/msdn-files/027/001/733/msdncompositedoc.xml
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.