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 閱讀(267)
評論(0) 編輯 收藏 所屬分類:
VBA