Try public function addory(id as integer, byref listview as variant) end function
AddOrg( ID,Treeview,Option ListView) if isobject(listView) then else endif
可以用Option 选项来设定参数,用Option 设定的参数是可选参数.
Public Function addorg(Optional ByVal id As String, Optional ByVal treeview As String, Optional ByVal listview As String) '代码 End Function
Public Function addorg(id,treeview,Optional listview)
Public Function addorg(id, treeview As Object, Optional listview1 As Object) If TypeOf listview1 Is listview Then endifend function
Public Function addorg(id,tvwObject As Object, Optional lvwObject As Object) If Not IsMissing(lvwObject) Then '假如lvwObject已经传入,则执行该段代码 Else '假如lvwObject未传入,则执行该段代码 End If End Function
我用的是 if not (lvwobject is nothing) then
end if也可以吧?
把第三个参数声明为option就OK!
使用 IsMissing 来判断是否传了参数
Function addorg(Byval id as integer,ParamArray objSource()) Dim intCount As Integer Dim i As Integer
On Error Resume Next '// 取得传入的参数的个数 intCount = UBound(objSource)
For i = 0 To intCount Select Case TypeName(objSource(i)) Case "什么类型" '做什么事 End Select Next End Function
public function addory(id as integer, byref listview as variant)
end function
if isobject(listView) then else endif
'代码
End Function
If Not IsMissing(lvwObject) Then
'假如lvwObject已经传入,则执行该段代码
Else
'假如lvwObject未传入,则执行该段代码
End If
End Function
if not (lvwobject is nothing) then
end if也可以吧?
把第三个参数声明为option就OK!
Dim intCount As Integer
Dim i As Integer
On Error Resume Next
'// 取得传入的参数的个数
intCount = UBound(objSource)
For i = 0 To intCount
Select Case TypeName(objSource(i))
Case "什么类型"
'做什么事 End Select
Next
End Function