VBA使用EXCEL读取身份证阅读器获得证件信息

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

VBA使用EXCEL读取身份证阅读器获得证件信息本代码实现了在EXCEL中调用精伦身份证阅读器控件(可在网上百度精伦二次开发包,里面有)读取身份证信息,可根据实际情况修改相关代码,源文件可在EXCELhome网站搜索下载。PrivateDeclareFunctionInitCommLibSdtapi.dll(ByValiPortAsInteger)AsIntegerPrivateDeclareFunctionCloseCommLibSdtapi.dll()AsIntegerPrivateDeclareFunctionAuthenticateLibSdtapi.dll()AsIntegerPrivateDeclareFunctionReadBaseInfosLibSdtapi.dll(ByValinameAsString,ByValisexAsString,ByValfolkAsString,ByValbirthdayAsString,ByValcodeAsString,ByValaddrAsString,ByValagencyAsString,ByValstartdateAsString,ByValenddateAsString)AsIntegerSub启动_Click()'OnErrorResumeNextDimn,ret,nLenDiminameAsString*31DimisexAsString*3DimfolkAsString*10DimcodeAsString*19DimaddrAsString*71DimbirthdayAsString*9DimstartdateAsString*9DimenddateAsString*9DimagencyAsString*31DimMsgAsString*300DimMsg1AsString*256DimIINSNDNAsString*64DimSAMIDAsString*36DimLenTAsIntegerret=InitComm(1001)IfErrThenErr.ClearMsgBox端口错误,vbOKOnly,提示ExitSubEndIfret=Authenticate()If(ret)Then''MsgBox找到卡,正在读卡...'ret=MsgBox(找到卡,正在读卡...,vbOKOnly+vbInformation,提示)ret=ReadBaseInfos(iname,isex,folk,birthday,code,addr,agency,startdate,enddate)If(ret)Then'MsgBox读卡成功!'姓名Range(a1)=Trim(iname)'性别Range(a2)=Trim(isex)'民族Range(a3)=Trim(folk)'出生年Range(a4)=Left(Trim(birthday),4)+年+Mid(Trim(birthday),5,2)+月+Mid(Trim(birthday),7,2)+日Range(b4)=Trim(birthday)'住址Range(a5)=Trim(addr)'公民身份号码Range(a6)=Trim(code)'签发机关Range(a7)=Trim(agency)'有效期限Range(a8)=Trim(enddate)IfTrim(enddate)=长期ThenRange(b8)=Left(Trim(startdate),4)+.+Mid(Trim(startdate),5,2)+.+Mid(Trim(startdate),7,2)+---长期ElseRange(b8)=Left(Trim(startdate),4)+.+Mid(Trim(startdate),5,2)+.+Mid(Trim(startdate),7,2)+---+Left(Trim(enddate),4)+.+Mid(Trim(enddate),5,2)+.+Mid(Trim(enddate),7,2)EndIf'显示照片'Pic.Picture=LoadPicture(App.Path+\photo.bmp)ElseMsgBox读卡不成功!请重新开始读卡。EndIfElseMsgBox未找到卡!请将卡远离后再置于机具上。EndIfret=CloseComm()EndSub

1 / 3
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功