【发布时间】:2014-10-22 06:46:25
【问题描述】:
我在我的代码中找不到任何错误,但是“需要对象”错误不断出现。 有人可以帮忙吗?我一直在这个,试图修复它半小时,我仍然找不到问题。任何帮助,将不胜感激。 谢谢!
Private Sub cmdCost_Click()
Dim strCost As Integer
Dim strFixedCost As Integer
Dim strResourceCost As Integer
Dim wksResources As Worksheet
Set wksResources = Application.Workbooks(1).Worksheets("Resources")
Set strFixedCost = 140
If cResources.Text = "" = False Then
If Val(tQuantity.Text) > 0 Then
wksResources.Select
wksResources.Range("B2").Select
Do Until ActiveCell.Value = cResources.Text
ActiveCell.Offset(1, 0).Select
Loop
Set strResourceCost = ActiveCell.Offset(0, 3).Value
Set strCost = strFixedCost + (Val(strResourceCost) * tQuantity)
MsgBox " The price is" & " $" + strCost, Buttons:=vbOKOnly, Title:="Cost"
Else
MsgBox " You have not chosen a quantity.", Buttons:=vbOKOnly, Title:="Cost"
End If
Else
MsgBox " You have not chosen a resource.", Buttons:=vbOKOnly, Title:="Cost"
End If
End Sub
【问题讨论】:
-
哪一行报错?
标签: vba object compilation required