3
所以我有一个叫Transactions的类,我把所有的功能放在那里。问题是,当我尝试调用该特定函数并将其分配给一个变量时,会出现一个“ByRef参数类型不匹配”错误,这个错误会一直困扰着我。请帮助:)如何分配一个返回值给变量的函数?
Public Function GetUserID(name As String) As Integer
Dim gotID As Integer
Dim rec As Recordset
Call connectDB
sSQL = "select ID from User where Name ='" & name & "'"
Set rec = CurrentDb.OpenRecordset(sSQL)
gotID = rec(0)
GetUserID = gotID
End Function
Private Sub btnAcctAdd_Click()
Dim tr As Transactions
Set tr = New Transactions
Dim ID as Integer
Dim name, username, password As String
name = cmbName.Value
'MsgBox name
ID = tr.GetUserID(name)
'MsgBox ID
End Sub
它的工作!谢谢! :D – Ali 2011-04-26 01:28:11
实际上,原始代码中的另外两个变量是Variant,而不是Object。 – RolandTumble 2011-04-26 18:12:00