function sfzjy(num)
if len(num)=15 then
  cID = left(num,6)&"19"&right(num,9)
elseif len(num)=17 or len(num)=18 then
  cID = left(num,17)
end if
nSum=mid(cID,1,1) * 7
nSum=nsum+mid(cID,2,1) * 9 
check_number=12-nsum mod 11
If check_number=10 then
  check_number="X" 
elseIf check_number=12 then
  check_number="1"
elseif check_number=11 then
  check_number="0"
End if
sfzjy=check_number
End function
function chk()
xian=Trim(usercode.value)
iscode = false
if (len(xian)=15) then
  if (IsNumeric(xian)) then iscode = true
elseif (len(xian)=18) then
  if (IsNumeric(xian)) then
   iscode = true
  elseif (IsNumeric(left(xian,17)) and right(xian,1)="x") then
   iscode = true
  end if
end if
if (iscode) then
  lenx=len(xian)       
   if lenx=15 then 
    aa=mid(xian,15,1)
   end if 
   if  lenx=18 then
    aa=mid(xian,17,1)
   end if 
  if aa mod 2=0 then 
    xb="female"
    else
    xb="male"
  end if 
  if lenx=18 then
  if mid(xian,18,1)<>cstr(sfzjy(xian)) then
    jieguo.value = "error"
    else
     jieguo.value = "ok" 
     get_code_area(xian)
  end if
    else
    xian = left(xian,6)&"19"&right(xian,9)&cstr(sfzjy(xian))
    jieguo.value = "new:"&xian
    get_code_area(xian)
  end if
else
  jieguo.value = "input error"
end if
End function
function getcode()
if (chkinput()) then
  dim i
  code = left(area3.value,6)
  list = ""
  if Len(yy.value)=2 then
   code = code&"19"&yy.value
  else
   code = code&yy.value
  end if
  code = code&chknum(mm.value)&chknum(dd.value)
  Randomize
  for i=1 to 10
   temp = code&getrnd(int(499* Rnd)*2+cint(sex.value))
   temp = temp&sfzjy(temp&"1")
   list = list&temp&chr(10)&chr(13)
  next
  code_list.value = list
end if
end function
function getrnd(code)
select case len(code)
case 0:getrnd="000"
case 1:getrnd="00"&cstr(code)
case 2:getrnd="0"&cstr(code)
case 3:getrnd=cstr(code)
end select
end function
function chknum(num)
dim temp
temp = cint(num)
if temp<10 then
chknum = "0"&temp
else
chknum = temp
end if
end function