求VB编程题答案.马上就要高一信息技术会考了~
来源:学生作业帮 编辑:搜搜考试网作业帮 分类:综合作业 时间:2024/08/20 02:52:59
求VB编程题答案.马上就要高一信息技术会考了~
1、随机产生10个两位整数,按由小到大顺序输出.
2、求N!=1*2*3…*N,N值由键盘输入.
3、输入某人年龄,输出其所属年龄段;18岁以下(不含18)为青少年;18---60为中青年;60岁以上(含60)为老年.
4、在文本框中任意输入两个数,单击“比较”按钮后,将其中的
最大值显示在下方标签中;单击“清除”按钮清除各项数值.
1、随机产生10个两位整数,按由小到大顺序输出.
2、求N!=1*2*3…*N,N值由键盘输入.
3、输入某人年龄,输出其所属年龄段;18岁以下(不含18)为青少年;18---60为中青年;60岁以上(含60)为老年.
4、在文本框中任意输入两个数,单击“比较”按钮后,将其中的
最大值显示在下方标签中;单击“清除”按钮清除各项数值.
![求VB编程题答案.马上就要高一信息技术会考了~](/uploads/image/z/3245947-43-7.jpg?t=%E6%B1%82VB%E7%BC%96%E7%A8%8B%E9%A2%98%E7%AD%94%E6%A1%88.%E9%A9%AC%E4%B8%8A%E5%B0%B1%E8%A6%81%E9%AB%98%E4%B8%80%E4%BF%A1%E6%81%AF%E6%8A%80%E6%9C%AF%E4%BC%9A%E8%80%83%E4%BA%86%7E)
第二题
Private Sub Command1_Click()
Dim a As Long
Dim s As Long
Dim i As Long
If Trim(Text1.Text) = "" Then
MsgBox "请填写N的值!", vbInformation, "-提 示-"
Exit Sub
ElseIf Trim(Text1.Text) = "0" Then
MsgBox "0不参于计算!", vbInformation, "-提 示-"
Exit Sub
Else
a = CLng(Trim(Text1.Text))
s = 1
For i = 1 To a
s = s * i
Next i
Text2.Text = Str(s)
End If
End Sub
第三题:
Private Sub Command1_Click()
If Trim(Text1.Text) = "" Then
MsgBox "请输入年龄", vbInformation, "-提 示-"
Text1.SetFocus
Exit Sub
Else
Dim a As Integer
a = CInt(Text1.Text)
Select Case a
Case Is < 18
Text2.Text = "青 年"
Case Is < 60
Text2.Text = "中青年"
Case Is >= 60
Text2.Text = "老 年"
End Select
End If
End Sub
第四题:
第四题:
Private Sub Command1_Click()
If Trim(Text1.Text) = "" Or Trim(Text2.Text) = "" Then
MsgBox "请填完整"
ElseIf CLng(Text1.Text) = CLng(Text2.Text) Then
Label1.Caption = "两数相等!"
ElseIf CLng(Text1.Text) > CLng(Text2.Text) Then
Label1.Caption = Text1.Text
Else
Label1.Caption = Text2.Text
End If
End Sub
Private Sub Command2_Click()
Text1.Text = "" And Text2.Text = ""
End Sub
第一题:见图/
![](http://img.wesiedu.com/upload/6/d8/6d8a387c8fbb8807c40d23f5ac34e97d.jpg)
Private Sub Command1_Click()
Dim a As Long
Dim s As Long
Dim i As Long
If Trim(Text1.Text) = "" Then
MsgBox "请填写N的值!", vbInformation, "-提 示-"
Exit Sub
ElseIf Trim(Text1.Text) = "0" Then
MsgBox "0不参于计算!", vbInformation, "-提 示-"
Exit Sub
Else
a = CLng(Trim(Text1.Text))
s = 1
For i = 1 To a
s = s * i
Next i
Text2.Text = Str(s)
End If
End Sub
第三题:
Private Sub Command1_Click()
If Trim(Text1.Text) = "" Then
MsgBox "请输入年龄", vbInformation, "-提 示-"
Text1.SetFocus
Exit Sub
Else
Dim a As Integer
a = CInt(Text1.Text)
Select Case a
Case Is < 18
Text2.Text = "青 年"
Case Is < 60
Text2.Text = "中青年"
Case Is >= 60
Text2.Text = "老 年"
End Select
End If
End Sub
第四题:
第四题:
Private Sub Command1_Click()
If Trim(Text1.Text) = "" Or Trim(Text2.Text) = "" Then
MsgBox "请填完整"
ElseIf CLng(Text1.Text) = CLng(Text2.Text) Then
Label1.Caption = "两数相等!"
ElseIf CLng(Text1.Text) > CLng(Text2.Text) Then
Label1.Caption = Text1.Text
Else
Label1.Caption = Text2.Text
End If
End Sub
Private Sub Command2_Click()
Text1.Text = "" And Text2.Text = ""
End Sub
第一题:见图/
![](http://img.wesiedu.com/upload/6/d8/6d8a387c8fbb8807c40d23f5ac34e97d.jpg)