?
Solved

code needed for serial number

Posted on 2003-02-24
5
Medium Priority
?
138 Views
Last Modified: 2010-05-01
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
0
Comment
Question by:hjaycox
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
5 Comments
 
LVL 4

Expert Comment

by:RanaHossain
ID: 8013591
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
 
LVL 4

Expert Comment

by:RanaHossain
ID: 8013592
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
 
LVL 1

Expert Comment

by:Bandy
ID: 8013723
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
 
LVL 4

Accepted Solution

by:
RanaHossain earned 400 total points
ID: 8013769
agreed... you need regular expression library.but the advantage is - as you said, it is very powerful.
0
 
LVL 1

Expert Comment

by:Bandy
ID: 8013773
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

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question