一个将15的身份证号升为18位的函数(VB)

来源:互联网 发布:证件照相机软件 编辑:程序博客网 时间:2024/05/17 07:21
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>

在新旧身份证同时并存使用的情况下,最好将升位后的18位方式保存在中,下面的函数能将用户输入的15位数据转化为18位。

FunctionIDCode15to18(sCode15AsString)AsString
   '* 功能:将15的身份证号升为18位(根据GB11643-1999)
   '* 参数:原来的号码
   '* 返回:升位后的18位号码
   DimiAsInteger
   DimnumAsInteger
   DimcodeAsString
   num=0
   IDCode15to18=Left(sCode15,6)+"19"+Right(sCode15,9)
   ' 计算校验位
   Fori=18To2Step-1
     num=num+(2^(i-1)Mod11)*(Mid(IDCode15to18,19-i,1))
   Nexti
   num=numMod11
   SelectCasenum
   Case0
     code="1"
   Case1
     code="0"
   Case2
     code="X"
   CaseElse
     code=Trim(Str(12-num))
   EndSelect
   IDCode15to18=IDCode15to18+code
EndFunction


<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
原创粉丝点击