Match is a function which provides extensive pattern matching in
a string. It can simplify validation of text box input either in
batch after all input is complete or upon a lost focus event for
a given text box. 

The syntax for MATCH is

          Dmy% = MATCH(Pattern$, Text$, StartingAt%)

MATCH provides support for the following wildcard characters:

		 "!" - a letter  
		 "#" - a number
		 "&" - a letter or number 
		 "?" - any character
		 "\" - an escape character to match literally
                       with any reserved wildcards.

MATCH allows you to specify where in the string to start the matching process 
and returns the position in the string where the first match occurred or
0 if no match.

Two versions of the MATCH function are provided in this zip. GEMATCH.BAS is
a "generic" version of MATCH which uses intrinsic MSBASIC functions.
MhMATCH.BAS is designed for users of Microhelp's Muscle product.  

Any comments or suggestions? Leave mail to BRIAN MCMAHON 75430,717



Examples:

   Dmy% = MATCH ("#!ABC", "1 ABC 2AABC", 1)
             (Dmy%=6)

   Dmy%= MATCH ("\#\#\#", "123###4567###", 7)
             (Dmy%=11)

   IF MATCH("###-##-####", txtSS.Text, 1) = 0 OR LEN(txtSS.Text) >11 THEN
	MSGBOX "Invalid Social Security Number"
        txtSS.SETFOCUS
   END IF

or perhaps use MATCH in a function like this

  FUNCTION ValidCompanyData% ()

     ValidCompanyData% = FALSE

     tmp$ = LTRIM$(RTRIM$(frmPrCoCode.txtFein.text))

     IF LEN(tmp$) <> 9 OR MATCH("#########", tmp$, 1) <> 1 THEN
         MSGBOX "Bad Federal Id Number (Must Be ALL Numeric): " + tmp$
         frmPrCoCode.SHOW
         frmPrCoCode.txtFein.SETFOCUS
         EXIT FUNCTION
     END IF

     IF MATCH("&", (frmPrCoCode.txtCity.text), 1) = 0 THEN
         MSGBOX "Bad Company City"
         frmPrCoCode.SHOW
         frmPrCoCode.txtCity.SETFOCUS
         EXIT FUNCTION
     END IF

     IF MATCH("!!", (frmPrCoCode.txtState.text), 1) = 0 THEN
         MSGBOX "Bad Company State"
         frmPrCoCode.SHOW
         frmPrCoCode.txtState.SETFOCUS
         EXIT FUNCTION
     END IF

     IF MATCH("&&&&&", (frmPrCoCode.txtZip.text), 1) = 0 THEN
         MSGBOX "Bad Company Zip"
         frmPrCoCode.SHOW
         frmPrCoCode.txtZip.SETFOCUS
         EXIT FUNCTION
     END IF

     IF MATCH("&", (frmPrCoCode.txtName.text), 1) = 0 THEN
         MSGBOX "Bad Company Name"
         frmPrCoCode.SHOW
         frmPrCoCode.txtName.SETFOCUS
         EXIT FUNCTION
     END IF

     IF MATCH("&", (frmPrCoCode.txtAddress.text), 1) = 0 THEN
         MSGBOX "Bad Company Address"
         frmPrCoCode.SHOW
         frmPrCoCode.txtAddress.SETFOCUS
         EXIT FUNCTION
     END IF

     ValidCompanyData% = TRUE

 END FUNCTION

 