Public Function GetSomeData(Optional Byref rsItem as ADODB.Recordset ) As Boolean
…………
…………
End Function
这个函数,我想判断一下,调用者是否传递了RS过来,以便做不同的动作。
请各位大侠帮忙了。
...全文
51632打赏收藏
判断函数调用者是否传递optional参数的方法
我现在写一个公共函数,里面有一些可选参数(optional) ,我现在如何知道调用者有没有传值过来.比如: Public Function GetSomeData(Optional Byref rsItem as ADODB.Recordset ) As Boolean ………… ………… End Function 这个函数,我想判断一下,调用者是否传递了RS过来,以便做不同的动作。 请各位大侠帮忙了。
Public Function GetSomeData(Optional ByRef rsItem as Variant ) As Boolean
Dim rsItemUse As ADODB.Recordset
If IsMissing(rsItem) Then
MsgBox "no"
Else
MsgBox "yes"
Set rsItemUse = rsItem
If rsItemUse Is Nothing Then
MsgBox "nothing"
Else
MsgBox "yes"
End If
End If
Dim r As New Recordset
Private Sub Form_Load()
aa
End Sub
Sub aa(Optional b As Recordset = Nothing)
If b Is Nothing Then
Beep
End If
End Sub
this can do
Public Function GetSomeData(Optional ByRef rsItem) As Boolean
Dim rsItemUse As ADODB.Recordset
If IsMissing(rsItem) Then
MsgBox "no"
Else
MsgBox "yes"
Set rsItemUse = rsItem
If rsItemUse Is Nothing Then
MsgBox "nothing"
Else
MsgBox "yes"
End If
End If