关于 vb 编程的问题 一下代码能简单化吗 还有输入其他的数字 返回为0 怎么写

来源:百度知道 编辑:UC知道 时间:2024/07/04 18:03:27
Private Sub Command1_Click()
If Text1.Text = "" Then
MsgBox "请输入号码“"

ElseIf Text1.Text = 27756 Then
Label1.Caption = 50000
Text1.Text = ""
ElseIf Text1.Text = 54342 Then
Label1.Caption = 50000
Text1.Text = ""

ElseIf Text1.Text = 27484 Then
Label1.Caption = 1000
Text1.Text = ""

ElseIf Text1.Text = 57254 Then
Label1.Caption = 1000
Text1.Text = ""

ElseIf Text1.Text = 26643 Then
Label1.Caption = 1000
Text1.Text = ""

ElseIf Text1.Text = 27545 Then
Label1.Caption = 0
Text1.Text = ""
'Else

Else

End If

End Sub

Private Sub Command1_Click()
select case Text1.Text
case ""
MsgBox "请输入号码“"
case "27756","54342"
Label1.Caption = 50000
case "27484","57254" ,"26643"
Label1.Caption = 1000
case "27545"
Label1.Caption = 0
end select
Text1.Text = ""
End Sub

至于你的说的“返回”,我不知道是什么意思。

select case text1.text
case zhengquehaoma
^
case zhengquehaoma
^
等等等等
case else ' 不正确号码
msgbox("请输入正确号码。")
end select

可以用一个select case语句,看起来更简洁,也解决了其他情况,很简单就自己研究下吧!