五笔打字通主页
VB程序题:编写一个“个人简历表”程序。该程序运行后,用户在文本框中输入姓名和年龄,选择性别、职业、学历和个人兴趣等个人信息。单击“递交”按钮运行后,在右侧Label1控件显示具体个人信息;单击“重置”按钮则清除输入的信息和所做的选择。运行界面如图2.3.8所示。 ---- 来自五笔打字通
图2.3.8
提示:
利用xb,xl,zy,ah字符串变量分别保存性别、学历、职业和爱好的选择信息。
解题:按要求建立相应的控件,代码如下:
Dim xm As String, nl As String, xb As String, xl As String, zy As String
Dim ah1 As String, ah2 As String, ah3 As String, ah4 As String
Private Sub Check1_Click()
If Check1.Value = 1 Then ah1 = "旅游" Else ah1 = "" ’通过点击事件,即时赋值给ah1
End Sub
Private Sub Check2_Click()
If Check2.Value = 1 Then ah2 = "体育" Else ah2 = ""
End Sub
Private Sub Check3_Click()
If Check3.Value = 1 Then ah3 = "音乐" Else ah3 = ""
End Sub
Private Sub Check41_Click()
If Check4.Value = 1 Then ah4 = "集邮" Else ah4 = ""
End Sub
Private Sub Check4_Click()
If Check4.Value = 1 Then ah4 = "集邮" Else ah4 = ""
End Sub
Private Sub Command1_Click() ’递交
Label1.Caption = "简历" & vbCrLf & "姓名:" & xm & vbCrLf & "年龄:" & nl & vbCrLf & "性别:" & xb & vbCrLf & "学历:" & xl & vbCrLf & "职业:" & zy & vbCrLf & "爱好:" & ah1 & ah2 & ah3 & ah4
End Sub
Private Sub Command2_Click() '重置
Text1 = "": xm = ""
Text2 = "": nl = ""
Text3 = ""
Check1.Value = 0: ah1 = ""
Check2.Value = 0: ah2 = ""
Check3.Value = 0: ah3 = ""
Check4.Value = 0: ah4 = ""
End Sub
Private Sub Option1_Click()
If Option1.Value = True Then xb = "男"
End Sub
Private Sub Option2_Click()
If Option2.Value = True Then xb = "女"
End Sub
Private Sub Option3_Click()
If Option3.Value = True Then xl = "大学"
End Sub
Private Sub Option4_Click()
If Option4.Value = True Then xl = "本科"
End Sub
Private Sub Option5_Click()
If Option5.Value = True Then xl = "研究生"
End Sub
Private Sub Option6_Click()
If Option6.Value = True Then zy = "教师"
End Sub
Private Sub Option7_Click()
If Option7.Value = True Then zy = "医生"
End Sub
Private Sub Option8_Click()
If Option8.Value = True Then zy = "公务员"
End Sub
Private Sub Text1_Change()
xm = Text1.Text
End Sub
Private Sub Text2_Change()
nl = Text2.Text
End Sub
Visual Basic程序设计教程(第四版) (龚沛曾等编)课后实验源码
来源:济亨网
本文链接:http://wb86.com/post/142.html