这是我的代码:
Dim Seat As String
Seat = txtSeat.Text.ToUpper
If Seat = "BOX" Then
txtPrice.Text = FormatCurrency(75)
ElseIf Seat = "PAVILION" Then
txtPrice.Text = FormatCurrency(30)
ElseIf Seat = "LAWN" Then
txtPrice.Text = FormatCurrency(21)
End If
我的考验是,当用户没有输入其中一个指定的单词时,我需要显示一个信息/错误框。因此,如果我改为输入“cat”,则会出现一个消息框,上面写着“请改为输入列表中的一个席位:)”。
编辑:
完美的mootinator thankyoU!
答案 0 :(得分:1)
Else
MessageBox.Show("Please instead type one of the seats in the list :)")
答案 1 :(得分:0)
请参阅MessageBox.Show()
,假设这是一个WinForms上下文。如果是web,请尝试jQuery UI的dialog
。
答案 2 :(得分:0)
我知道你已经有了答案,但是使用“select case”代替所有if语句,这是你的答案。
Dim Seat As String
Seat = txtSeat.Text.ToUpper
Select Case Seat
Case "BOX"
txtPrice.Text = FormatCurrency(75)
Case "PAVILION"
txtPrice.Text = FormatCurrency(30)
Case "LAWN"
txtPrice.Text = FormatCurrency(21)
Case Else
MessageBox.Show("Please instead type one of the seats in the list :)")
End Select