Jcat
宠辱不惊,闲看庭前花开花落~~
posts - 173,comments - 67,trackbacks - 0
Note If you need to determine whether an optional argument was passed to a function, you MUST declare the optional argument as a Variant data type. Then you can use the IsMissing function within the procedure.

Option Explicit

Function explicitType(Optional s As Integer)
    Debug.Assert IsNull(s) 
= False
    Debug.Assert IsMissing(s) 
= False
    Debug.Assert s 
= 0
    explicitType 
= s
End Function


Function variantType(Optional s)
    Debug.Assert IsNull(s) 
= False
    Debug.Assert IsMissing(s) 
= True
    'Debug.Print s  'Error 448
    variantType = s
End Function


Sub test()
    Debug.Print explicitType()
    Debug.Print variantType()
End Sub

posted on 2008-03-28 16:23 Jcat 阅读(250) 评论(0)  编辑  收藏 所属分类: VBA

只有注册用户登录后才能发表评论。


网站导航: