现要求编写VB程序,界面如图1所示。程序功能如下:在文本框Text1中输入身份证号码,单击“识别”按钮Command1,在标签Label3中输出对应的性别。 具体方法为:(1)若身份证号为15位,则根据第15位数字来判断,若为偶数则性别“女”,否则为“男”;(2)若身份证号为18位,则根据第17位数字来判断,若为偶数时则性别为“女”,否则为“男”。图1
(1)
应用程序界面设计时,为添加“识别”按钮,应使用图2中“控件工具箱”中的(填写相应编号),并修改图3“属性窗口”中,将属性值设置为“识别”
(2)
请根据题意将下列程序补充完整 Dim x As String, n As Integer, s As String x = Text1.Text n = Len(x) If n = 15 Then s = Mid(, Len(x), 1) If Val(s) Mod 2 = 0 Then Text2.Text = "女" Else Text2.Text = "男" End If Else s=Mid(x, 17, 1) If Then Text2.Text = "男" Else Text2.Text = "女" End If End If
答案: 【1】3【2】Caption
【1】x【2】val(s) mod 2 =1