LOCAL lcBase lcBase=thisform.txtmy1.getvalue() DO case CASE EMPTY(lcBase) thisform.omessage.warning("enter a six digit serial number base first") CASE LEN(ALLTRIM(lcbase))!=6 thisform.omessage.warning("serial number base must be six digits") OTHERWISE &&calculate it. lcBase=ALLTRIM(lcBase) **following is copied and modified from gencode.prg * #include 'ezwindefs.h' **removed the #include and supplied it with the m.crootkey and m.cleft LOCAL cRootKey, cLeft, cRight, cSerialNo * Build root system registry key, minus version number. * Used to create unique serial numbers for each application. m.cRootKey = 'Software\company\softwarename\' m.cLeft = lcBase &&LEFT(m.cLeft, 6) m.cRight = m.cRootKey + STRTRAN(STRTRAN(m.cLeft, ' ', ''), '-', '') m.cSerialNo = m.cLeft + '-' + PADL(SYS(2007, UPPER(m.cRight) + LOWER(m.cRight)), 5, '0') thisform.txtmy2.setvalue(PROPER(m.cSerialNo)) _cliptext=(PROPER(m.cSerialNo)) endcase