我无法让我If语句正常工作。VB.NET:在“If”语句中使用“或”与“等于或大于”
我想要我的If语句来检查我的两个文本框:名称和价格,以便它们不是空的,并检查价格文本框,以便输入价格/编号等于或大于1.00。
现在,即使我输入的数字/价格高于1.00,程序也会发出警告,但只有当数字小于1.00时才会执行此操作。
我正在使用:Option Explicit On,Option Strict On。
Private Sub Btn_ResrvCancl_Click(sender As Object, e As EventArgs) Handles Btn_ResrvCancl.Click, listBox_ResDisplay.DoubleClick
If listBox_ResDisplay.SelectedIndex >= 0 Then
If radioBtn_Reserve.Checked Then
If txt_Name.Text Is "" Or txt_Price.Text Is "" Or CDbl(txt_Price.Text) > 1.0 Then
MessageBox.Show("Please enter both your name and price (price must be 1.00 or higher)")
Else
Dim BookingSuccess As Boolean = seatmgrResrv.NewReservation(txt_Name.Text, CDbl(txt_Price.Text), CInt(listBox_ResDisplay.SelectedItem.ToString.Substring(0, 15).Trim))
If BookingSuccess = False Then
MessageBox.Show("Already booked!")
End If
End If
Else
Dim CancelSuccess As Boolean = seatmgrResrv.CancelReservation(CInt(listBox_ResDisplay.SelectedItem.ToString.Substring(0, 15).Trim))
If CancelSuccess = False Then
MessageBox.Show("Already vacant!")
End If
End If
UppsateList()
Else
MessageBox.Show("Please choose a seat")
End If
End Sub
对于我个人理解,这一定是不正确的行,但我不能找出解决的办法:
If txt_Name.Text Is "" Or txt_Price.Text Is "" Or CDbl(txt_Price.Text) > 1.0
提前感谢!
谢谢@jmcilhinney,我真的很感谢你的帮助! – Televinken 2014-12-02 22:02:08