单击“输入身份z号”按钮,使用inputbox函数d出以下对话框:身份z号=InputBox(对话框提示信息,标题,默认值)当用户选择inputbox的“确定”按钮时,执行身份z号判断 *** 作。具体判断过程如下:当用户输入的身份z号不足18位时,使用msgbox函数。
应用技巧:1)检测身份z号长度使用Len()函数;2)使用If选择结构判断身份z号是否正确:if身份z号不足18位thenmsgbox给出提示else在指定控件显示出生年月、性别以及年龄EndIf3、当信息录入正确时,在指定控件显示出生年月、性别以及年龄。1)在名为shengri的文本框中显示出生年月,出生年月为身份z号的第7-14位提示:使用mid函数2)在名为nianling的文本框中显示年龄提示:使用year(now())获得系统日期的年份,使用mid函数获取身份z中年份信息,相减可得年龄。3)在名为xingbie的文本框中显示性别:身份z的第17位为偶数则为“女”,奇数为“男”。Dim x As String
Private Sub Command1_Click()
Text1Text = Text1Text & "1"
End Sub
Private Sub Command10_Click()
Text1Text = Text1Text & "6"
End Sub
Private Sub Command11_Click()
Text1Text = Text1Text & "9"
End Sub
Private Sub Command12_Click()
If Label1Caption = "+" Then
Text1Text = Trim(Str(Val(x) + Val(Text1Text)))
End If
If Label1Caption = "-" Then
Text1Text = Trim(Str(Val(x) - Val(Text1Text)))
End If
If Label1Caption = "" Then
Text1Text = Trim(Str(Val(x) Val(Text1Text)))
End If
If Label1Caption = "/" Then
If Val(Text1Text) = 0 Then
Text1Text = "除数不能为零"
Else
If -1 < Val(x) / Val(Text1Text) And Val(x) / Val(Text1Text) < 0 Then
Text1Text = Trim("-0" & Trim(Str(Abs(Val(x) / Val(Text1Text)))))
Else
If 0 < Val(x) / Val(Text1Text) And Val(x) / Val(Text1Text) < 1 Then
Text1Text = Trim("0" & Trim(Str(Val(x) / Val(Text1Text))))
Else
Text1Text = Trim(Str(Val(x) / Val(Text1Text)))
End If
End If
End If
End If
End Sub
Private Sub Command13_Click()
x = Text1Text
Text1Text = ""
Label1Caption = "+"
End Sub
Private Sub Command14_Click()
x = Text1Text
Text1Text = ""
Label1Caption = "-"
End Sub
Private Sub Command15_Click()
x = Text1Text
Text1Text = ""
Label1Caption = ""
End Sub
Private Sub Command16_Click()
x = Text1Text
Text1Text = ""
Label1Caption = "/"
End Sub
Private Sub Command17_Click()
Text1Text = ""
Text1SetFocus
End Sub
Private Sub Command18_Click()
Unload Me
End Sub
Private Sub Command2_Click()
Text1Text = Text1Text & "4"
End Sub
Private Sub Command3_Click()
Text1Text = Text1Text & "7"
End Sub
Private Sub Command4_Click()
Text1Text = Text1Text & "0"
End Sub
Private Sub Command5_Click()
Text1Text = Text1Text & "2"
End Sub
Private Sub Command6_Click()
Text1Text = Text1Text & "5"
End Sub
Private Sub Command7_Click()
Text1Text = Text1Text & "8"
End Sub
Private Sub Command8_Click()
Text1Text = Text1Text & ""
End Sub
Private Sub Command9_Click()
Text1Text = Text1Text & "3"
End Sub
Private Sub Form_Load()
Label1Visible = False
End SubDimxAsString\x0d\PrivateSubCommand1_Click()\x0d\Text1Text=Text1Text&"1"\x0d\EndSub\x0d\PrivateSubCommand10_Click()\x0d\Text1Text=Text1Text&"6"\x0d\EndSub\x0d\PrivateSubCommand11_Click()\x0d\Text1Text=Text1Text&"9"\x0d\EndSub\x0d\PrivateSubCommand12_Click()\x0d\IfLabel1Caption="+"Then\x0d\Text1Text=Trim(Str(Val(x)+Val(Text1Text)))\x0d\EndIf\x0d\IfLabel1Caption="-"Then\x0d\Text1Text=Trim(Str(Val(x)-Val(Text1Text)))\x0d\EndIf\x0d\IfLabel1Caption=""Then\x0d\Text1Text=Trim(Str(Val(x)Val(Text1Text)))\x0d\EndIf\x0d\IfLabel1Caption="/"Then\x0d\IfVal(Text1Text)=0Then\x0d\Text1Text="除数不能为零"\x0d\Else\x0d\If-1回答于 2022-12-14
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)