VB 输入一个数字(1~7)分别利用分支if语句.seleck语句和choose函数三种方法.显示用英文形式的星期一至星期日
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/20 22:31:46
VB 输入一个数字(1~7)分别利用分支if语句.seleck语句和choose函数三种方法.显示用英文形式的星期一至星期日
VB 输入一个数字(1~7)分别利用分支if语句.seleck语句和choose函数三种方法.显示用英文形式的星期一至星期日
VB 输入一个数字(1~7)分别利用分支if语句.seleck语句和choose函数三种方法.显示用英文形式的星期一至星期日
窗体上放3个按钮和1个文本框,文本框用于输入1~7
Private Sub Command1_Click()
Dim d As Integer,s As String
d = Val(Text1.Text)
If d = 1 Then
s = "Monday"
ElseIf d = 2 Then
s = "Tuesday"
ElseIf d = 3 Then
s = "Wednesday"
ElseIf d = 4 Then
s = "Thursday"
ElseIf d = 5 Then
s = "Friday"
ElseIf d = 6 Then
s = "Saturday"
ElseIf d = 7 Then
s = "Sunday"
Else
s = "您的输入有误!"
End If
MsgBox s
End Sub
Private Sub Command2_Click()
Dim d As Integer,s As String
d = Val(Text1.Text)
Select Case d
Case 1
s = "Monday"
Case 2
s = "Tuesday"
Case 3
s = "Wednesday"
Case 4
s = "Thursday"
Case 5
s = "Friday"
Case 6
s = "Saturday"
Case 7
s = "Sunday"
Case Else
s = "您的输入有误!"
End Select
MsgBox s
End Sub
Private Sub Command3_Click()
Dim d As Integer,s As String
d = Val(Text1.Text)
If d >= 1 And d