展开全部
你要的程序来了,已经验证OK!!!
Private Sub Command1_Click()
If Not IsNumeric(Text1.Text) Then
MsgBox "输入的不是数字!", 64, "输入错误"
Exit Sub
End If
Select Case Val(Text1.Text)
Case 1
MsgBox "星期一"
Case 2
MsgBox "星期二"
Case 3
MsgBox "星期三"
Case 4
MsgBox "星期四"
Case 5
MsgBox "星期五"
Case 6
MsgBox "星期六"
Case 7
MsgBox "星期天"
Case Else
MsgBox "输入了小于1或大于7的数!", 64, "输入错误"
End Select
End Sub
Private Sub Command2_Click()
If Not IsNumeric(Text1.Text) Or Val(Text1.Text) > 7 Or Val(Text1.Text) < 1 Then
MsgBox "输入错误!", 64, "提示"
Exit Sub
End If
MsgBox WeekdayName(Text1.Text),64,"共同学习"
End Sub
给你提供两种方法,你自己试试吧,以后共同学习!!!
Private Sub Command1_Click()
If Not IsNumeric(Text1.Text) Then
MsgBox "输入的不是数字!", 64, "输入错误"
Exit Sub
End If
Select Case Val(Text1.Text)
Case 1
MsgBox "星期一"
Case 2
MsgBox "星期二"
Case 3
MsgBox "星期三"
Case 4
MsgBox "星期四"
Case 5
MsgBox "星期五"
Case 6
MsgBox "星期六"
Case 7
MsgBox "星期天"
Case Else
MsgBox "输入了小于1或大于7的数!", 64, "输入错误"
End Select
End Sub
Private Sub Command2_Click()
If Not IsNumeric(Text1.Text) Or Val(Text1.Text) > 7 Or Val(Text1.Text) < 1 Then
MsgBox "输入错误!", 64, "提示"
Exit Sub
End If
MsgBox WeekdayName(Text1.Text),64,"共同学习"
End Sub
给你提供两种方法,你自己试试吧,以后共同学习!!!
展开全部
Shared a As Integer '定义变量
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
a = Val(TextBox1.Text) '获取输入值,转换为整型数字,并赋值
'以下是判断输入内容,并显示结果
Select Case a
Case 1
Label3.Text = "Monday"
Case 2
Label3.Text = "Tuesday"
Case 3
Label3.Text = "Wedesday"
Case 4
Label3.Text = "Thursday"
Case 5
Label3.Text = "Friday"
Case 6
Label3.Text = "Saturday"
Case 7
Label3.Text = "Sunday"
Case Else
Label3.Text = "Wrong input!" '对于1~7之外的输入,显示错误信息。
End Select
textbox1.clear() '清空文本框,以便再次输入
End Sub
'以上是用label控件来显示结果,当然用msgbox也可以。
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
a = Val(TextBox1.Text) '获取输入值,转换为整型数字,并赋值
'以下是判断输入内容,并显示结果
Select Case a
Case 1
Label3.Text = "Monday"
Case 2
Label3.Text = "Tuesday"
Case 3
Label3.Text = "Wedesday"
Case 4
Label3.Text = "Thursday"
Case 5
Label3.Text = "Friday"
Case 6
Label3.Text = "Saturday"
Case 7
Label3.Text = "Sunday"
Case Else
Label3.Text = "Wrong input!" '对于1~7之外的输入,显示错误信息。
End Select
textbox1.clear() '清空文本框,以便再次输入
End Sub
'以上是用label控件来显示结果,当然用msgbox也可以。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
Select Case Val(InputBox("请输入一个数字(1~7)"))
Case 1
MsgBox "星期一"
Case 2
MsgBox "星期二"
Case 3
MsgBox "星期三"
Case 4
MsgBox "星期四"
Case 5
MsgBox "星期五"
Case 6
MsgBox "星期六"
Case 7
MsgBox "星期天"
Case Else
MsgBox "输入错误!"
End Select
End Sub
Select Case Val(InputBox("请输入一个数字(1~7)"))
Case 1
MsgBox "星期一"
Case 2
MsgBox "星期二"
Case 3
MsgBox "星期三"
Case 4
MsgBox "星期四"
Case 5
MsgBox "星期五"
Case 6
MsgBox "星期六"
Case 7
MsgBox "星期天"
Case Else
MsgBox "输入错误!"
End Select
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
Dim a As String
a = Text1.Text
Select Case a
Case "1"
Label1.Caption = "Monday"
Case "2"
Label1.Caption = "Tuesday"
Case "3"
Label1.Caption = "Wedesday"
Case "4"
Label1.Caption = "Thursday"
Case "5"
Label1.Caption = "Friday"
Case "6"
Label1.Caption = "Saturday"
Case "7"
Label1.Caption = "Sunday"
Case Else
MsgBox "您输入的数值不再范围之内"
Text1.Text = ""
End Select
End Sub
Dim a As String
a = Text1.Text
Select Case a
Case "1"
Label1.Caption = "Monday"
Case "2"
Label1.Caption = "Tuesday"
Case "3"
Label1.Caption = "Wedesday"
Case "4"
Label1.Caption = "Thursday"
Case "5"
Label1.Caption = "Friday"
Case "6"
Label1.Caption = "Saturday"
Case "7"
Label1.Caption = "Sunday"
Case Else
MsgBox "您输入的数值不再范围之内"
Text1.Text = ""
End Select
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
Private Sub Command1_Click()
Select Case Text1.Text
Case 1
Label2.Caption = " Monday"
Case 2
Label2.Caption = "Tuesday"
Case 3
Label2.Caption = "Tuesday"
Case 4
Label2.Caption = "Thursday"
Case 5
Label2.Caption = "Friday"
Case 6
Label2.Caption = "Saturday"
Case 7
Label2.Caption = "Sunday"
Case Else
Label2.Caption = "Wrong input!"
End Select
End Sub
按钮动作,只需要拖好控件 其他都不用定义
Select Case Text1.Text
Case 1
Label2.Caption = " Monday"
Case 2
Label2.Caption = "Tuesday"
Case 3
Label2.Caption = "Tuesday"
Case 4
Label2.Caption = "Thursday"
Case 5
Label2.Caption = "Friday"
Case 6
Label2.Caption = "Saturday"
Case 7
Label2.Caption = "Sunday"
Case Else
Label2.Caption = "Wrong input!"
End Select
End Sub
按钮动作,只需要拖好控件 其他都不用定义
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询