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 阅读(261)
评论(0) 编辑 收藏 所属分类:
VBA