如果用户输入“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
答案 0 :(得分: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
答案 1 :(得分:0)
如果txtchange.Text =“A”或者txtchange.Text =“a”那么 lbloutput.Caption =“Apple”
答案 2 :(得分:0)
你可以拥有: 如果txtchange.Text =“A”或者txtchange.Text =“a”那么 lbloutput.Caption =“Apple”