VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsMisc2B"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
' Guide to Perplexed: Parameter examples
' Copyright (c) 1997 by Desaware Inc. All Rights Reserved
Option Explicit

Private Declare Sub agCopyData Lib "apigid32.dll" (source As Any, dest As Any, ByVal count As Long)

Public Type usertype
   x(20) As Byte
   y As Integer
End Type

Private m_UserType As usertype


Public Function Optional1(Optional vr As Variant) As Variant
   If IsMissing(vr) Then
      Debug.Print "Variable vr is missing"
   Else
      Debug.Print "Variable vr is present"
   End If
End Function

Public Function Optional2(Optional vr As String) As Variant
   If IsMissing(vr) Then
      Debug.Print "Variable vr is missing"
   Else
      Debug.Print "Variable vr is: " & vr
   End If
End Function

' With default values
Public Function Optional3(Optional vr As String = "A Default Value") As Variant
   If IsMissing(vr) Then
      Debug.Print "Variable vr is missing"
   Else
      Debug.Print "Variable vr is: " & vr
   End If
End Function

Public Function ParamArrayDemo(ParamArray vr())
   Debug.Print "Parameters range from: " & LBound(vr) & " to " & UBound(vr)
End Function

Public Function ArrayParam(param() As Byte)
   Debug.Print "Param() range is: " & LBound(param) & " to "; UBound(param)
End Function

Public Property Get UserProperty() As usertype
   Dim TempUserType As usertype
   TempUserType.y = 77  ' Test value
   UserProperty = TempUserType
End Property

Public Property Let UserProperty(vNewValue As usertype)
    Dim TempUserType As usertype
    TempUserType = vNewValue
    Debug.Print TempUserType.y
End Property

' This process converts a user defined type into an array
' and returns the array
Public Property Get UserTypeEquiv() As Variant
   Dim TempArray() As Byte
   ReDim TempArray(Len(m_UserType))
   m_UserType.y = 77 ' New value for demo purposes
   agCopyData m_UserType, TempArray(0), Len(m_UserType)
   UserTypeEquiv = TempArray()
End Property

' This process receives an array, and
' converts it into the user type
Public Property Let UserTypeEquiv(ByVal vNewValue As Variant)
   Dim TempArray() As Byte
   If VarType(vNewValue) <> vbArray + vbByte Then
      MsgBox "Invalid data type"
      Exit Property
   End If
   TempArray() = vNewValue 'Must do this - see text
   agCopyData TempArray(0), m_UserType, Len(m_UserType)
   Debug.Print "UserTypeEquiv set: Y = " & m_UserType.y
End Property

