【发布时间】:2014-04-29 19:05:58
【问题描述】:
我有一个带有组合框的数据网格。此组合框包含数字和文本。我想设置一个条件,如果组合框文本是 BOGO 或 Complimentary,那么我的变量 dblQty 应该是 0。
我可以让它在一个条件下工作 BOGO,(见下面的代码),但我似乎无法让它在两个条件下工作,我试过 BOGO Or Complimentary 但我得到了一个无法转换为布尔值错误。
Private Sub grdNewInvoice_CurrentCellDirtyStateChanged(sender As Object, e As EventArgs) Handles grdNewInvoice.CurrentCellDirtyStateChanged
'Procedure runs when the combobox in the datagrid changes.
'The procedure calculates the amount * the quantity in the datagrid
'It also updates the label with the total
'Local variables
Dim dblQty As Double
Dim dblPrice As Double
'Calculate the amount * quantity
For index As Integer = 0 To grdNewInvoice.RowCount - 1
If grdNewInvoice.Rows(index).Cells(1).Value.ToString = "BOGO" Then
dblQty = 0
dblPrice = Convert.ToDouble(grdNewInvoice.Rows(index).Cells(2).Value)
grdNewInvoice.Rows(index).Cells(3).Value = dblPrice * dblQty
Else
dblQty = Convert.ToDouble(grdNewInvoice.Rows(index).Cells(1).Value)
dblPrice = Convert.ToDouble(grdNewInvoice.Rows(index).Cells(2).Value)
grdNewInvoice.Rows(index).Cells(3).Value = dblPrice * dblQty
End If
Next
'Update the total label.
PublicSubs.totalDataGrid()
End Sub
【问题讨论】:
-
你为
BOGO Or Complimentary尝试的代码是什么??