正如标题所解释的那样,我得到的错误是NETPRICE = NET * TOTWIDTH和NET =" PRODUCTBOX.LIST(PRODUCTBOX.ListIndex,2)"。还是习惯了VBA。我尝试将变量重新分配为整数,但这并没有帮助。有什么建议?
Private Sub ADDBTN_Click()
Dim THRESWIDTH As Variant
Dim THRESWIDTHRND As Variant
Dim TOTWIDTH As Integer
Dim NET As Variant
Dim THRES_DES As String
Dim THRESHOLD As String
Dim FINISH As String
Dim NETPRICE As Integer
THRESWIDTH = InputBox("WHAT IS THE WIDTH OF THE THRESHOLD IN INCHES? (i.e. 36,36 1/2)")
TOTWIDTH = Application.RoundUp(THRESWIDTH / 12, 0)
THRESWIDTHRND = TOTWIDTH * 12
If FINISHBOX.Value = "A - MILL FINISH ALUMINUM" Then
NET = "PRODUCTBOX.LIST(PRODUCTBOX.ListIndex, 2)"
ElseIf FINISHBOX.Value = "B - MILL FINISH EXTRUDED BRONZE (BRASS)" Then
NET = "PRODUCTBOX.LIST(PRODUCTBOX.ListIndex, 4)"
ElseIf FINISHBOX.Value = "D - DARK BRONZE ANODIZED" Then
NET = "PRODUCTBOX.LIST(PRODUCTBOX.ListIndex, 6)"
ElseIf FINISHBOX.Value = "G - GOLD ANODIZED" Then
NET = "PRODUCTBOX.LIST(PRODUCTBOX.ListIndex, 8)"
Else
End If
NETPRICE = NET * TOTWIDTH
答案 0 :(得分:0)
想出来,变量未正确分配,并且必须将Val()放在我的字符串变量周围。
Private Sub ADDBTN_Click()
Dim THRESWIDTH As Variant
Dim THRESWIDTHRND As Variant
Dim TOTWIDTH As Integer
Dim NET As Variant
Dim THRES_DES As String
Dim THRESHOLD As String
Dim FINISH As String
Dim NETPRICE As Variant
Dim NETA As Variant
Dim NETB As Variant
Dim NETD As Variant
Dim NETG As Variant
THRESWIDTH = InputBox("WHAT IS THE WIDTH OF THE THRESHOLD IN INCHES? (i.e. 36,36 1/2)")
TOTWIDTH = Application.RoundUp(THRESWIDTH / 12, 0)
THRESWIDTHRND = Val(TOTWIDTH) * 12
NETA = PRODUCTBOX.LIST(PRODUCTBOX.ListIndex, 2)
NETB = PRODUCTBOX.LIST(PRODUCTBOX.ListIndex, 4)
NETD = PRODUCTBOX.LIST(PRODUCTBOX.ListIndex, 6)
NETG = PRODUCTBOX.LIST(PRODUCTBOX.ListIndex, 8)
If FINISHBOX.Value = "A - MILL FINISH ALUMINUM" Then
NET = Val(NETA)
ElseIf FINISHBOX.Value = "B - MILL FINISH EXTRUDED BRONZE (BRASS)" Then
NET = Val(NETB)
ElseIf FINISHBOX.Value = "D - DARK BRONZE ANODIZED" Then
NET = Val(NETD)
ElseIf FINISHBOX.Value = "G - GOLD ANODIZED" Then
NET = Val(NETG)
Else
End If
NETPRICE = Val(NET) * Val(TOTWIDTH)