'Author: wuguoying Imports System.Drawing.Text Imports System.Object Imports System.Text 'Imports Microsoft.VisualBasic.Strings Public Class frmMain Inherits System.Windows.Forms.Form Public Declare Function InitComm Lib "termb.dll" (ByVal port As Integer) As Integer Public Declare Function Authenticate Lib "termb.dll" () As Integer Public Declare Function Read_Content Lib "termb.dll" (ByVal active As Integer) As Integer Public Declare Function Read_Content_Path Lib "termb.dll" (ByVal fileName As String, ByVal active As Integer) As Integer Public Declare Function CloseComm Lib "termb.dll" () As Integer Public Const Ver = "身份证阅读演示程序 公安部第一研究所 版权所有" Public Const ReadState = "读卡状态" Public Const OpenPortError = "打开串口失败!" Public Const TimeOutError = "通讯超时!" Public Const RecError = "操作失败!" Public Const XpError = "相片解码错误!" Public Const FileExtError = "wlt文件后缀错误!" Public Const FileOpenError = "wlt文件打开错误!" Public Const FileFormatError = "wlt文件格式错误!" Public Const JmError = "软件未授权!" Public Const CardError = "卡认证错误!" Public Const UnknowError = "未知错误!" Public Const Swipe = "请放卡..." Public Const ReadOK = "读卡成功!请放下一张卡..." Public Const ReadError = "读卡失败!请重新放卡..." Public Const NewAddError = "读最新住址失败!" Public Const IINSNDNError = "读芯片号失败!" Public Const Reading = "正在读卡..." Const NewAddOK = "读最新住址成功!请放下一张卡..." Public bcc, TimeOutFlag As Byte Dim state As Boolean Dim OutByte() As Byte Dim RecCount, i, j As Long Dim ReadResult, PortNum As Integer Dim ComPort, ReadMode, tmp As String Dim nametmp, sextmp, nationtmp, borntmp, addresstmp, IDNtmp, regtmp, datetmp As String Dim RecTmp(), RecByte() As String Dim ReadCount As Long Friend WithEvents Label1 As System.Windows.Forms.Label Dim CommFlag As Boolean #Region " Windows 窗体设计器生成的代码 " Public Sub New() MyBase.New() '该调用是 Windows 窗体设计器所必需的。 InitializeComponent() '在 InitializeComponent() 调用之后添加任何初始化 End Sub '窗体重写 dispose 以清理组件列表。 Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean) If disposing Then If Not (components Is Nothing) Then components.Dispose() End If End If MyBase.Dispose(disposing) End Sub 'Windows 窗体设计器所必需的 Private components As System.ComponentModel.IContainer '注意: 以下过程是 Windows 窗体设计器所必需的 '可以使用 Windows 窗体设计器修改此过程。 '不要使用代码编辑器修改它。 Friend WithEvents lblSignGov As System.Windows.Forms.Label Friend WithEvents Photo As System.Windows.Forms.PictureBox Friend WithEvents lblID As System.Windows.Forms.Label Friend WithEvents lblAddress As System.Windows.Forms.Label Friend WithEvents lblBirth As System.Windows.Forms.Label Friend WithEvents lblNation As System.Windows.Forms.Label Friend WithEvents lblSex As System.Windows.Forms.Label Friend WithEvents lblName As System.Windows.Forms.Label Friend WithEvents lblLimitedDate As System.Windows.Forms.Label Friend WithEvents sbState As System.Windows.Forms.StatusBar Friend WithEvents Timer1 As System.Windows.Forms.Timer Friend WithEvents Timer2 As System.Windows.Forms.Timer Friend WithEvents ReadingState As System.Windows.Forms.StatusBarPanel Friend WithEvents ReaderState As System.Windows.Forms.StatusBarPanel Friend WithEvents Button1 As System.Windows.Forms.Button Friend WithEvents Button2 As System.Windows.Forms.Button Friend WithEvents lblNewAddress As System.Windows.Forms.Label Private Sub InitializeComponent() Me.components = New System.ComponentModel.Container Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(frmMain)) Me.lblSignGov = New System.Windows.Forms.Label Me.Photo = New System.Windows.Forms.PictureBox Me.lblID = New System.Windows.Forms.Label Me.lblAddress = New System.Windows.Forms.Label Me.lblBirth = New System.Windows.Forms.Label Me.lblNation = New System.Windows.Forms.Label Me.lblSex = New System.Windows.Forms.Label Me.lblName = New System.Windows.Forms.Label Me.lblLimitedDate = New System.Windows.Forms.Label Me.sbState = New System.Windows.Forms.StatusBar Me.ReadingState = New System.Windows.Forms.StatusBarPanel Me.ReaderState = New System.Windows.Forms.StatusBarPanel Me.Timer1 = New System.Windows.Forms.Timer(Me.components) Me.Timer2 = New System.Windows.Forms.Timer(Me.components) Me.Button1 = New System.Windows.Forms.Button Me.Button2 = New System.Windows.Forms.Button Me.lblNewAddress = New System.Windows.Forms.Label Me.Label1 = New System.Windows.Forms.Label CType(Me.Photo, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.ReadingState, System.ComponentModel.ISupportInitialize).BeginInit() CType(Me.ReaderState, System.ComponentModel.ISupportInitialize).BeginInit() Me.SuspendLayout() ' 'lblSignGov ' Me.lblSignGov.Anchor = System.Windows.Forms.AnchorStyles.None Me.lblSignGov.BackColor = System.Drawing.Color.Transparent Me.lblSignGov.Font = New System.Drawing.Font("SimSun", 15.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.lblSignGov.ForeColor = System.Drawing.Color.Blue Me.lblSignGov.ImeMode = System.Windows.Forms.ImeMode.NoControl Me.lblSignGov.Location = New System.Drawing.Point(197, 360) Me.lblSignGov.Name = "lblSignGov" Me.lblSignGov.Size = New System.Drawing.Size(432, 24) Me.lblSignGov.TabIndex = 60 ' 'Photo ' Me.Photo.BackColor = System.Drawing.Color.Transparent Me.Photo.ImeMode = System.Windows.Forms.ImeMode.NoControl Me.Photo.Location = New System.Drawing.Point(616, 128) Me.Photo.Name = "Photo" Me.Photo.Size = New System.Drawing.Size(120, 144) Me.Photo.TabIndex = 59 Me.Photo.TabStop = False ' 'lblID ' Me.lblID.Anchor = System.Windows.Forms.AnchorStyles.None Me.lblID.BackColor = System.Drawing.Color.Transparent Me.lblID.Font = New System.Drawing.Font("SimSun", 15.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.lblID.ForeColor = System.Drawing.Color.Blue Me.lblID.ImeMode = System.Windows.Forms.ImeMode.NoControl Me.lblID.Location = New System.Drawing.Point(253, 300) Me.lblID.Name = "lblID" Me.lblID.Size = New System.Drawing.Size(328, 28) Me.lblID.TabIndex = 58 Me.lblID.TextAlign = System.Drawing.ContentAlignment.MiddleLeft ' 'lblAddress ' Me.lblAddress.Anchor = System.Windows.Forms.AnchorStyles.None Me.lblAddress.BackColor = System.Drawing.Color.Transparent Me.lblAddress.Font = New System.Drawing.Font("SimSun", 15.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.lblAddress.ForeColor = System.Drawing.Color.Blue Me.lblAddress.ImageAlign = System.Drawing.ContentAlignment.TopLeft Me.lblAddress.ImeMode = System.Windows.Forms.ImeMode.NoControl Me.lblAddress.Location = New System.Drawing.Point(141, 216) Me.lblAddress.Name = "lblAddress" Me.lblAddress.Size = New System.Drawing.Size(440, 56) Me.lblAddress.TabIndex = 57 ' 'lblBirth ' Me.lblBirth.Anchor = System.Windows.Forms.AnchorStyles.None Me.lblBirth.BackColor = System.Drawing.Color.Transparent Me.lblBirth.Font = New System.Drawing.Font("SimSun", 15.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.lblBirth.ForeColor = System.Drawing.Color.Blue Me.lblBirth.ImeMode = System.Windows.Forms.ImeMode.NoControl Me.lblBirth.Location = New System.Drawing.Point(141, 184) Me.lblBirth.Name = "lblBirth" Me.lblBirth.Size = New System.Drawing.Size(256, 24) Me.lblBirth.TabIndex = 56 Me.lblBirth.TextAlign = System.Drawing.ContentAlignment.MiddleLeft ' 'lblNation ' Me.lblNation.Anchor = System.Windows.Forms.AnchorStyles.None Me.lblNation.BackColor = System.Drawing.Color.Transparent Me.lblNation.Font = New System.Drawing.Font("SimSun", 15.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.lblNation.ForeColor = System.Drawing.Color.Blue Me.lblNation.ImeMode = System.Windows.Forms.ImeMode.NoControl Me.lblNation.Location = New System.Drawing.Point(429, 152) Me.lblNation.Name = "lblNation" Me.lblNation.Size = New System.Drawing.Size(136, 48) Me.lblNation.TabIndex = 55 ' 'lblSex ' Me.lblSex.Anchor = System.Windows.Forms.AnchorStyles.None Me.lblSex.BackColor = System.Drawing.Color.Transparent Me.lblSex.Font = New System.Drawing.Font("SimSun", 15.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.lblSex.ForeColor = System.Drawing.Color.Blue Me.lblSex.ImeMode = System.Windows.Forms.ImeMode.NoControl Me.lblSex.Location = New System.Drawing.Point(141, 152) Me.lblSex.Name = "lblSex" Me.lblSex.Size = New System.Drawing.Size(80, 24) Me.lblSex.TabIndex = 54 Me.lblSex.TextAlign = System.Drawing.ContentAlignment.MiddleLeft ' 'lblName ' Me.lblName.Anchor = System.Windows.Forms.AnchorStyles.None Me.lblName.BackColor = System.Drawing.Color.Transparent Me.lblName.Font = New System.Drawing.Font("SimSun", 15.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.lblName.ForeColor = System.Drawing.Color.Blue Me.lblName.ImeMode = System.Windows.Forms.ImeMode.NoControl Me.lblName.Location = New System.Drawing.Point(141, 120) Me.lblName.Name = "lblName" Me.lblName.Size = New System.Drawing.Size(424, 24) Me.lblName.TabIndex = 53 Me.lblName.TextAlign = System.Drawing.ContentAlignment.MiddleLeft ' 'lblLimitedDate ' Me.lblLimitedDate.Anchor = System.Windows.Forms.AnchorStyles.None Me.lblLimitedDate.BackColor = System.Drawing.Color.Transparent Me.lblLimitedDate.Font = New System.Drawing.Font("SimSun", 15.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.lblLimitedDate.ForeColor = System.Drawing.Color.Blue Me.lblLimitedDate.ImeMode = System.Windows.Forms.ImeMode.NoControl Me.lblLimitedDate.Location = New System.Drawing.Point(197, 392) Me.lblLimitedDate.Name = "lblLimitedDate" Me.lblLimitedDate.Size = New System.Drawing.Size(544, 24) Me.lblLimitedDate.TabIndex = 61 ' 'sbState ' Me.sbState.Font = New System.Drawing.Font("SimSun", 12.0!) Me.sbState.ImeMode = System.Windows.Forms.ImeMode.NoControl Me.sbState.Location = New System.Drawing.Point(0, 551) Me.sbState.Name = "sbState" Me.sbState.Panels.AddRange(New System.Windows.Forms.StatusBarPanel() {Me.ReadingState, Me.ReaderState}) Me.sbState.ShowPanels = True Me.sbState.Size = New System.Drawing.Size(794, 24) Me.sbState.TabIndex = 63 ' 'ReadingState ' Me.ReadingState.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring Me.ReadingState.Name = "ReadingState" Me.ReadingState.Width = 388 ' 'ReaderState ' Me.ReaderState.AutoSize = System.Windows.Forms.StatusBarPanelAutoSize.Spring Me.ReaderState.Name = "ReaderState" Me.ReaderState.Width = 388 ' 'Timer1 ' ' 'Timer2 ' ' 'Button1 ' Me.Button1.BackColor = System.Drawing.SystemColors.Control Me.Button1.Font = New System.Drawing.Font("SimSun", 10.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte)) Me.Button1.Image = CType(resources.GetObject("Button1.Image"), System.Drawing.Image) Me.Button1.ImageAlign = System.Drawing.ContentAlignment.TopCenter Me.Button1.Location = New System.Drawing.Point(88, 488) Me.Button1.Name = "Button1" Me.Button1.Size = New System.Drawing.Size(72, 56) Me.Button1.TabIndex = 64 Me.Button1.Text = "最新住址" Me.Button1.TextAlign = System.Drawing.ContentAlignment.BottomCenter Me.Button1.UseVisualStyleBackColor = False ' 'Button2 ' Me.Button2.BackColor = System.Drawing.SystemColors.Control Me.Button2.Font = New System.Drawing.Font("SimSun", 10.5!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte)) Me.Button2.Image = CType(resources.GetObject("Button2.Image"), System.Drawing.Image) Me.Button2.ImageAlign = System.Drawing.ContentAlignment.TopCenter Me.Button2.Location = New System.Drawing.Point(232, 488) Me.Button2.Name = "Button2" Me.Button2.Size = New System.Drawing.Size(64, 56) Me.Button2.TabIndex = 65 Me.Button2.Text = "退 出" Me.Button2.TextAlign = System.Drawing.ContentAlignment.BottomCenter Me.Button2.UseVisualStyleBackColor = False ' 'lblNewAddress ' Me.lblNewAddress.Anchor = System.Windows.Forms.AnchorStyles.None Me.lblNewAddress.BackColor = System.Drawing.Color.Transparent Me.lblNewAddress.Font = New System.Drawing.Font("SimSun", 15.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.lblNewAddress.ForeColor = System.Drawing.Color.FromArgb(CType(CType(192, Byte), Integer), CType(CType(0, Byte), Integer), CType(CType(0, Byte), Integer)) Me.lblNewAddress.ImeMode = System.Windows.Forms.ImeMode.NoControl Me.lblNewAddress.Location = New System.Drawing.Point(197, 424) Me.lblNewAddress.Name = "lblNewAddress" Me.lblNewAddress.Size = New System.Drawing.Size(544, 40) Me.lblNewAddress.TabIndex = 66 Me.lblNewAddress.TextAlign = System.Drawing.ContentAlignment.MiddleLeft ' 'Label1 ' Me.Label1.Anchor = System.Windows.Forms.AnchorStyles.None Me.Label1.BackColor = System.Drawing.Color.Transparent Me.Label1.Font = New System.Drawing.Font("SimSun", 15.0!, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, CType(0, Byte)) Me.Label1.ForeColor = System.Drawing.Color.Green Me.Label1.ImeMode = System.Windows.Forms.ImeMode.NoControl Me.Label1.Location = New System.Drawing.Point(312, 504) Me.Label1.Name = "Label1" Me.Label1.Size = New System.Drawing.Size(424, 24) Me.Label1.TabIndex = 67 Me.Label1.TextAlign = System.Drawing.ContentAlignment.MiddleLeft ' 'frmMain ' Me.AutoScaleBaseSize = New System.Drawing.Size(8, 19) Me.BackgroundImage = CType(resources.GetObject("$this.BackgroundImage"), System.Drawing.Image) Me.ClientSize = New System.Drawing.Size(794, 575) Me.Controls.Add(Me.Label1) Me.Controls.Add(Me.lblNewAddress) Me.Controls.Add(Me.Button2) Me.Controls.Add(Me.Button1) Me.Controls.Add(Me.sbState) Me.Controls.Add(Me.lblLimitedDate) Me.Controls.Add(Me.lblSignGov) Me.Controls.Add(Me.Photo) Me.Controls.Add(Me.lblID) Me.Controls.Add(Me.lblAddress) Me.Controls.Add(Me.lblBirth) Me.Controls.Add(Me.lblNation) Me.Controls.Add(Me.lblSex) Me.Controls.Add(Me.lblName) Me.Font = New System.Drawing.Font("SimSun", 12.0!, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, CType(134, Byte)) Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog Me.Name = "frmMain" Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen CType(Me.Photo, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.ReadingState, System.ComponentModel.ISupportInitialize).EndInit() CType(Me.ReaderState, System.ComponentModel.ISupportInitialize).EndInit() Me.ResumeLayout(False) End Sub #End Region Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Dim PortNum1, PortNum2 As Integer Dim ans As Integer Me.Text = Ver lblName.Text = "" lblSex.Text = "" lblAddress.Text = "" lblBirth.Text = "" lblID.Text = "" lblLimitedDate.Text = "" lblSignGov.Text = "" lblNation.Text = "" lblNewAddress.Text = "" Photo.Image = Nothing PortNum1 = 1 ans = InitComm(PortNum1) '开串口 If ans <> 1 Then PortNum2 = 2 ans = InitComm(PortNum2) '再开串口 If ans <> 1 Then 'MsgBox("打开串口失败!", , "错误") 'End PortNum2 = 1001 ans = InitComm(PortNum2) 'USB If ans <> 1 Then sbState.Panels(0).Text = "设备无法识别或通讯口错误!" Else sbState.Panels(1).Text = "连接USB" & "口,状态正常!" Timer2.Interval = 300 Timer2.Enabled = True state = True End If Else sbState.Panels(1).Text = "连接COM" & PortNum2 & "口,波特率115200,状态正常!" Timer2.Interval = 300 Timer2.Enabled = True state = True End If Else sbState.Panels(1).Text = "连接COM" & PortNum1 & "口,波特率115200,状态正常!" Timer2.Interval = 300 Timer2.Enabled = True state = True End If 'Timer2.Interval = 300 'Timer2.Enabled = True Timer1.Interval = 20000 Timer1.Enabled = False state = True End Sub Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick Dim ans As Integer 'Timer2.Enabled = False '显示状态 If state = True Then '读卡状态 Select Case ReadResult Case 0 sbState.Panels(0).Text = Swipe Case 1 sbState.Panels(0).Text = ReadOK Case 6 sbState.Panels(0).Text = NewAddError Case 7 sbState.Panels(0).Text = NewAddOK Case -1 '相片解码错误 'Call Display() 'If Not (Photo.Image Is Nothing) Then ' Photo.Image.Dispose() ' Photo.Image = Nothing 'End If sbState.Panels(0).Text = XpError Case -2 '解码错 sbState.Panels(0).Text = FileExtError Case -3 '解码错 sbState.Panels(0).Text = FileOpenError Case -4 '解码错 sbState.Panels(0).Text = FileFormatError Case -5 '软件未授权 sbState.Panels(0).Text = JmError Case Else '读卡失败 sbState.Panels(0).Text = ReadError End Select End If ans = Authenticate() '卡认证 '卡认证成功 If ans = 1 Then lblName.Text = "" lblSex.Text = "" lblAddress.Text = "" lblBirth.Text = "" lblID.Text = "" lblLimitedDate.Text = "" lblSignGov.Text = "" lblNation.Text = "" lblNewAddress.Text = "" Label1.Text = "" If Not (Photo.Image Is Nothing) Then 'Else Photo.Image.Dispose() Photo.Image = Nothing End If Application.DoEvents() sbState.Panels(0).Text = Reading ans = Read_Content(1) '读基本信息 Select Case ans Case 1 '读卡成功 ReadResult = 1 Call Display() Timer1.Enabled = True '// ReadCount = ReadCount + 1 '// MainForm.StatusBar1.Panels("count_status").Text = "计数:" + LTrim(Str(ReadCount)) '// Timer3.Enabled = True Photo.Image = System.Drawing.Image.FromFile("zp.bmp") '显示照片 Case 3 '读卡成功 ReadResult = 1 Call Display() Timer1.Enabled = True '// ReadCount = ReadCount + 1 '// MainForm.StatusBar1.Panels("count_status").Text = "计数:" + LTrim(Str(ReadCount)) '// Timer3.Enabled = True Label1.Text = "有指纹信息!" Photo.Image = System.Drawing.Image.FromFile("zp.bmp") '显示照片 Case -1 '相片解码错误 Call Display() If Not (Photo.Image Is Nothing) Then Photo.Image.Dispose() Photo.Image = Nothing End If ReadResult = -1 Case -2 'wlt文件后缀错误 ReadResult = -2 Case -3 'wlt文件打开错误 ReadResult = -3 Case -4 'wlt文件格式错误 ReadResult = -4 Case -5 '软件未授权 ReadResult = -5 Case Else '读卡失败 ReadResult = 2 End Select End If 'Timer2.Enabled = True End Sub Public Sub Display() Dim bytWZ(255) As Byte Dim bytName(29) As Byte Dim bytSex(1) As Byte Dim bytNation(3) As Byte Dim bytBirth(15) As Byte Dim bytAddress(69) As Byte Dim bytID(35) As Byte Dim bytSignGov(29) As Byte Dim bytStartDate(31) As Byte Dim bytEndDate(15) As Byte Dim strTemp As String Dim iLoop As Integer Dim uni As New UnicodeEncoding FileOpen(1, "wz.txt", OpenMode.Binary, OpenAccess.Read) FileGet(1, bytWZ) 'Console.WriteLine(hellow) FileClose(1) For iLoop = 0 To 29 bytName(iLoop) = bytWZ(iLoop) Next Me.lblName.Text = uni.GetString(bytName) For iLoop = 30 To 31 bytSex(iLoop - 30) = bytWZ(iLoop) Next 'Me.lblSex.Text = uni.GetString(bytSex) Select Case uni.GetString(bytSex) Case "0" Me.lblSex.Text = "未知" Case "1" Me.lblSex.Text = "男" Case "2" Me.lblSex.Text = "女" Case Else Me.lblSex.Text = "未说明" End Select For iLoop = 32 To 35 bytNation(iLoop - 32) = bytWZ(iLoop) Next Me.lblNation.Text = GetNation(uni.GetString(bytNation)) For iLoop = 36 To 51 bytBirth(iLoop - 36) = bytWZ(iLoop) Next strTemp = uni.GetString(bytBirth) Me.lblBirth.Text = strTemp.Substring(0, 4) & "年" & strTemp.Substring(4, 2) & "月" & strTemp.Substring(6, 2) & "日" For iLoop = 52 To 121 bytAddress(iLoop - 52) = bytWZ(iLoop) Next Me.lblAddress.Text = uni.GetString(bytAddress) For iLoop = 122 To 157 bytID(iLoop - 122) = bytWZ(iLoop) Next Me.lblID.Text = uni.GetString(bytID) For iLoop = 158 To 187 bytSignGov(iLoop - 158) = bytWZ(iLoop) Next Me.lblSignGov.Text = uni.GetString(bytSignGov) For iLoop = 188 To 219 bytStartDate(iLoop - 188) = bytWZ(iLoop) Next 'For iLoop = 201 To 216 ' bytEndDate(iLoop - 201) = bytWZ(iLoop ) 'Next strTemp = uni.GetString(bytStartDate) If Len(Trim(strTemp)) = 10 Then Me.lblLimitedDate.Text = strTemp.Substring(0, 4) & "年" & strTemp.Substring(4, 2) & "月" & strTemp.Substring(6, 2) & "日--" & strTemp.Substring(8, 2) Else Me.lblLimitedDate.Text = strTemp.Substring(0, 4) & "年" & strTemp.Substring(4, 2) & "月" & strTemp.Substring(6, 2) & "日--" & strTemp.Substring(8, 4) & "年" & strTemp.Substring(12, 2) & "月" & strTemp.Substring(14, 2) & "日" End If End Sub Public Function GetNation(ByVal strNationcode As String) As String Dim strNationArray As String() = {"汉", "蒙古", "回", "藏", "维吾尔", "苗", "彝", "壮", "布依", "朝鲜", "满", "侗", "瑶", "白", "土家", "哈尼", "哈萨克", "傣", "黎", "傈僳", "佤", "畲", "高山", "拉祜", "水", "东乡", "纳西", "景颇", "柯尔克孜", "土", "达斡尔", "仫佬", "羌", "布朗", "撒拉", "毛南", "仡佬", "锡伯", "阿昌", "普米", "塔吉克", "怒", "乌孜别克", "俄罗斯", "鄂温克", "德昂", "保安", "裕固", "京", "塔塔尔", "独龙", "鄂伦春", "赫哲", "门巴", "珞巴", "基诺"} If Trim(strNationcode) <> "" Then If ((CByte(Trim(strNationcode)) - 1) >= 0) And ((CByte(Trim(strNationcode)) - 1) <= 55) Then GetNation = strNationArray(CByte(Trim(strNationcode)) - 1) Else GetNation = "其他" End If End If End Function Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick Timer1.Enabled = False lblName.Text = "" lblSex.Text = "" lblAddress.Text = "" lblBirth.Text = "" lblID.Text = "" lblLimitedDate.Text = "" lblSignGov.Text = "" lblNation.Text = "" lblNewAddress.Text = "" Label1.Text = "" If Not (Photo.Image Is Nothing) Then 'Else Photo.Image.Dispose() Photo.Image = Nothing End If End Sub Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click CloseComm() Me.Close() 'End End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim iReturn As Integer Dim bytNewAddress(69) As Byte Dim uni As New UnicodeEncoding Timer1.Enabled = False iReturn = Read_Content(3) If iReturn = 1 Then 'sbState.Panels(0).Text = "读最新住址成功!" FileOpen(1, "newadd.txt", OpenMode.Binary, OpenAccess.Read) FileGet(1, bytNewAddress) FileClose(1) ReadResult = 7 Me.lblNewAddress.Text = uni.GetString(bytNewAddress) Else ReadResult = 6 'sbState.Panels(0).Text = "读最新住址失败!" End If Timer1.Enabled = True End Sub End Class