在VB6中提供了一个很好用的函数叫IsMissing,可以用来判断用户是否对缺省参数赋值,比如有以下一个函数体:
代码如下:
Public Property Get Item(Optional ByRef Index As Integer, Optional ByRef Name As String) As TDMAttachment
Dim i As Long
Dim lngIndex As Long
Dim strName As String
If Not IsMissing(Index) Then '如果输入了索引
If Not IsNumeric(Index) Then Exit Property
lngIndex = Val(Index)
If lngIndex >= 0 And lngIndex < m_lngCount Then
Set Item = m_objAttachments(lngIndex)
End If
ElseIf Not IsMissing(Name) Then '如果输入