【发布时间】:2018-10-08 22:44:07
【问题描述】:
我有一个问题,我的代码,一个简单的订单表格需要某些信息。当用户没有输入一条信息时,程序会显示一个对话框,然后用户点击 Okay 后,它仍然会计算信息。我是 VB 新手,所以这里是代码 sn-p:
If (CheckBox3.Checked = False And blueBlackQuantityTextBox.Text <> "" And blueBlackQuantityTextBox.Text > 0) Then
MessageBox.Show("Please check item you wish to purchase", "No Item Selected",
MessageBoxButtons.OK, MessageBoxIcon.Error)
Stop
End If
Const whiteBlackDicePrice = 6.25
Const redBlackDicePrice = 5.0
Const blueBlackDicePrice = 7.5
Const tax = 0.05
Dim whiteBlackSubTotal As Double = whiteBlackQuantityTextBox.Text * whiteBlackDicePrice
Dim redBlackSubTotal As Double = redBlackQuantityTextBox.Text * redBlackDicePrice
Dim blueBlackSubtotal As Double = blueBlackQuantityTextBox.Text * blueBlackDicePrice
'newBalanceResultLabel.Text = String.Format("{0:C2}", newBalance)
Dim subtotal As Double = whiteBlackSubTotal + redBlackSubTotal + blueBlackSubtotal
whiteBlackTotalsLabel.Text = String.Format("{0:C2}", whiteBlackSubTotal)
redBlackTotalsLabel.Text = String.Format("{0:C2}", redBlackSubTotal)
blueBlackTotalsLabel.Text = String.Format("{0:C2}", blueBlackSubtotal)
subtotalResultLabel.Text = String.Format("{0:C2}", subtotal)
在每个 IF 语句后加上一个 STOP,会导致程序崩溃,我只能让对话框说:好的。
请帮忙!
【问题讨论】:
-
我有一个临时解决方案。 dim count as integer = 0,并在每个 IF 语句后将 count 加 1。如果 count 为 = 0,则继续执行程序。谁能提供更好的解决方案?
-
你只显示一个 IF 语句
标签: vb.net