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 <= 7 Then
s = Choose(d, "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday")
Else
s = "您的输入有误!"
End If
MsgBox s
End Sub
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 <= 7 Then
s = Choose(d, "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday")
Else
s = "您的输入有误!"
End If
MsgBox s
End Sub
追问
你好 在帮忙看下这个问题吧...
http://zhidao.baidu.com/question/413079723.html?quesup2&oldq=1
追答
回答了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询