你好我嘗試編寫返回對象的功能,但它給了我一個參數不可選的錯誤,這是我的代碼如何接受參數的Visual Basic函數返回一個對象6
Public Function searchVehicle(c As String, v As Variant) As Collection
Dim qur As String
qur = "select * from [vehicle] where (" & c & " like '%" & v & "%')"
Set mobjRst = conn.execQuery(qur)
Dim tmpV As Vehicle
Dim res As Collection
With mobjRst
Do Until .EOF
Set tmpV = New Vehicle
Call tmpV.popVehicle(!ID, !make, !model, !purchaseyear, !totalmilage, !milageafterservice, !servicemilage, !description)
res.Add (tmpV)
.MoveNext
Loop
End With
searchVehicle = res
End Function
錯誤出現在哪一行? –
不會向我們顯示導致錯誤的代碼行,它最有可能是您的Vehicle類的popVehicle方法 - 但是直到您告訴我們它在哪條線上......這是一個猜測 – dbmitch
您如何調用該函數? – Smith