-5

如果用户输入“A”或“a”.. 输出是 Apple。这也适用于字母“B”“C”等等...我应该在哪里/如何放置和/或运算符?

Private Sub txtchange_Change()

If txtchange.Text = "A" Then
    lbloutput.Caption = "Apple"

ElseIf txtchange.Text = "B" Then
    lbloutput.Caption = "Banana"

ElseIf txtchange.Text = "C" Then
    lbloutput.Caption = "Cat"

ElseIf txtchange.Text = "D" Then
    lbloutput.Caption = "Dog"

Else
    lbloutput.Caption = "Not Found"

End If


End Sub
4

3 回答 3

1

为简单.. 使用 SELECT CASE

Private Sub txtchange_Change()

Select case Ucase(txtchange.Text)
case "A" : lbloutput.Caption = "Apple"
case "B" : lbloutput.Caption = "Banana"
case "C" : lbloutput.Caption = "Cat"
case "D" : lbloutput.Caption = "Dog"
case "RED" : lbloutput.BackColor = RGB(255, 0, 0)
case Else
  lbloutput.Caption = "Not Found"
End Select

End Sub
于 2013-07-11T14:08:51.710 回答
0

如果 txtchange.Text = "A" 或 txtchange.Text = "a" 那么 lbloutput.Caption = "Apple"

于 2013-08-06T07:03:47.023 回答
0

你可以有: If txtchange.Text = "A" OR txtchange.Text = "a" Then lbloutput.Caption = "Apple"

于 2013-11-26T18:51:51.873 回答