⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.vb

📁 vb.net 写的新旧身份证换算。
💻 VB
字号:
Public Class Form1
    Inherits System.Windows.Forms.Form

#Region " Windows 窗体设计器生成的代码 "

    Public Sub New()
        MyBase.New()

        '该调用是 Windows 窗体设计器所必需的。
        InitializeComponent()

        '在 InitializeComponent() 调用之后添加任何初始化

    End Sub

    '窗体重写处置以清理组件列表。
    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 Label1 As System.Windows.Forms.Label
    Friend WithEvents Label2 As System.Windows.Forms.Label
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents Button2 As System.Windows.Forms.Button
    Friend WithEvents Button3 As System.Windows.Forms.Button
    Friend WithEvents txt_old As System.Windows.Forms.TextBox
    Friend WithEvents txt_new As System.Windows.Forms.TextBox
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
        Me.Label1 = New System.Windows.Forms.Label()
        Me.Label2 = New System.Windows.Forms.Label()
        Me.txt_old = New System.Windows.Forms.TextBox()
        Me.txt_new = New System.Windows.Forms.TextBox()
        Me.Button1 = New System.Windows.Forms.Button()
        Me.Button2 = New System.Windows.Forms.Button()
        Me.Button3 = New System.Windows.Forms.Button()
        Me.SuspendLayout()
        '
        'Label1
        '
        Me.Label1.Location = New System.Drawing.Point(24, 24)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(80, 23)
        Me.Label1.TabIndex = 0
        Me.Label1.Text = "旧身份证号码"
        '
        'Label2
        '
        Me.Label2.Location = New System.Drawing.Point(24, 56)
        Me.Label2.Name = "Label2"
        Me.Label2.Size = New System.Drawing.Size(80, 23)
        Me.Label2.TabIndex = 1
        Me.Label2.Text = "新身份证号码"
        '
        'txt_old
        '
        Me.txt_old.Location = New System.Drawing.Point(104, 16)
        Me.txt_old.Name = "txt_old"
        Me.txt_old.Size = New System.Drawing.Size(136, 21)
        Me.txt_old.TabIndex = 2
        Me.txt_old.Text = ""
        '
        'txt_new
        '
        Me.txt_new.Location = New System.Drawing.Point(104, 48)
        Me.txt_new.Name = "txt_new"
        Me.txt_new.Size = New System.Drawing.Size(136, 21)
        Me.txt_new.TabIndex = 3
        Me.txt_new.Text = ""
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(40, 88)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(56, 23)
        Me.Button1.TabIndex = 4
        Me.Button1.Text = "查看"
        '
        'Button2
        '
        Me.Button2.Location = New System.Drawing.Point(104, 88)
        Me.Button2.Name = "Button2"
        Me.Button2.Size = New System.Drawing.Size(56, 23)
        Me.Button2.TabIndex = 5
        Me.Button2.Text = "退出"
        '
        'Button3
        '
        Me.Button3.Location = New System.Drawing.Point(168, 88)
        Me.Button3.Name = "Button3"
        Me.Button3.Size = New System.Drawing.Size(56, 23)
        Me.Button3.TabIndex = 6
        Me.Button3.Text = "关于"
        '
        'Form1
        '
        Me.AcceptButton = Me.Button1
        Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
        Me.ClientSize = New System.Drawing.Size(266, 127)
        Me.Controls.AddRange(New System.Windows.Forms.Control() {Me.Button3, Me.Button2, Me.Button1, Me.txt_new, Me.txt_old, Me.Label2, Me.Label1})
        Me.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedDialog
        Me.Icon = CType(resources.GetObject("$this.Icon"), System.Drawing.Icon)
        Me.MaximizeBox = False
        Me.Name = "Form1"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "身份证15位升18位计算"
        Me.ResumeLayout(False)

    End Sub

#End Region

    Private Function getCheckCode(ByVal SFZH As String) As String
        Dim strJiaoYan() As Char = {"1", "0", "X", "9", "8", "7", "6", "5", "4", "3", "2"}
        Dim intQuan() As Integer = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2, 1}
        Dim strTemp As String
        Dim intTemp As String
        Dim i As Integer

        strTemp = SFZH.Substring(0, 6) & "19" & SFZH.Substring(6)
        For i = 0 To strTemp.Length - 1
            intTemp = intTemp + Convert.ToInt32(strTemp.Substring(i, 1)) * intQuan(i)
        Next
        intTemp = intTemp Mod 11

        Return strTemp & strJiaoYan(intTemp)
    End Function


    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        
        If Len(txt_old.Text) <> 15 Then
            MessageBox.Show("旧身份证号码必须为15位!")
            Exit Sub
        End If
        If IsNumeric(txt_old.Text) = False Then
            MessageBox.Show("所输入的旧身份证号码必须全部为数字!")
            Exit Sub
        End If
        txt_new.Text = getCheckCode(txt_old.Text)
    End Sub

    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        End
    End Sub

    Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
        MessageBox.Show("本程序由东营市公安局交警支队 荣俊杰 制作 2004年4月", "关于本程序", MessageBoxButtons.OK, MessageBoxIcon.Information)
    End Sub

    
End Class

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -