VB小程序,身份证信息提取,有兴趣的童鞋可以试着操作一下,我将不定期的发一些有趣的VB小程序,
要求:输入身份证 码后可以识别年龄、性别,生日
程序启动时自动加载字体、字 、背景颜色
控件:4个Label标签控件、4个Textbox文本框控件、2个Command命令按钮
界面:
代码:
Option Explicit
Dim sfzh As String
Private Sub Command1_Click()
sfzh = InputBox(“请输入18位身份证 ”, “身份证提取程序”) ‘ 输入对话框使用
If Len(sfzh) < 18 Or Len(sfzh) > 18 Then
MsgBox “身份证 输入错误,请重新输入!”, vbOKOnly, “错误提醒”
Else
id = sfzh ‘身份证
tiqu (sfzh) ‘调用自定义tiqu过程
End If
End Sub
Private Sub Command2_Click()
End ‘退出
End Sub
Private Sub Form_Load()
AutoRedraw = True
Label1.ForeColor = RGB(0, 0, 0)
Label2.ForeColor = RGB(0, 0, 0)
Label3.ForeColor = RGB(0, 0, 0)
Label4.ForeColor = RGB(0, 0, 0)
Label1.FontName = “隶书”
Label2.FontName = “隶书”
Label3.FontName = “隶书”
Label4.FontName = “隶书”
Label1.FontSize = 12
Label2.FontSize = 12
Label3.FontSize = 12
Label4.FontSize = 12
id.FontName = “隶书”
shengri.FontName = “隶书”
xingbie.FontName = “隶书”
nianling.FontName = “隶书”
id.FontSize = 12
shengri.FontSize = 12
xingbie.FontSize = 12
nianling.FontSize = 12
Command1.BackColor = RGB(100, 200, 155)
Command2.BackColor = RGB(100, 200, 155)
Form1.BackColor = RGB(100, 200, 155)
Label1.BackColor = RGB(100, 200, 155)
Label2.BackColor = RGB(100, 200, 155)
Label3.BackColor = RGB(100, 200, 155)
Label4.BackColor = RGB(100, 200, 155)
End Sub
Public Sub tiqu(sfzh As String) ‘自定义过程
Dim x As Integer
shengri = Mid(sfzh, 7, 8) ‘生日’
nianling = Year(Now()) – Mid(sfzh, 7, 4) ‘年龄
x = Val(Mid(sfzh, 17, 1))
If x Mod 2 = 0 Then
xingbie = “女”
Else
xingbie = “男” ‘性别
End If
End Sub
如有不懂的地方,发我私信哦,让我们一起成长
声明:本站部分文章及图片源自用户投稿,如本站任何资料有侵权请您尽早请联系jinwei@zod.com.cn进行处理,非常感谢!