home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Visual Database / Visual BASIC 5.0 (Ent. Edition) / Vb5ent Extractor.EXE / VB / SAMPLES / PGUIDE / PROGWOB / PWOTESTC.CLS < prev    next >
Encoding:
Visual Basic class definition  |  1996-11-26  |  2.7 KB  |  101 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "TestClass"
  6. Attribute VB_GlobalNameSpace = False
  7. Attribute VB_Creatable = True
  8. Attribute VB_PredeclaredId = False
  9. Attribute VB_Exposed = False
  10. Option Explicit
  11. ' >> Best viewed in Full Module view. <<
  12. '
  13. ' Storage for debug ID number.
  14. Private mlngDebugID As Long
  15. Implements IDebug
  16.  
  17. ' Private storage for the user-defined
  18. '   type (UDT) that gets passed between
  19. '   objects.  The UDT must be declared
  20. '   Public in a standard module (see
  21. '   modFriends).  (In this example, mDemo
  22. '   serves as the storage for both the
  23. '   Demo property and the GetDemo/SetDemo
  24. '   Function/Sub pair.)
  25. Private mDemo As udtDEMO
  26.  
  27. ' Demo property:  The Property Get and Let
  28. ' -------------     for the Demo property
  29. '   show how property procedures declared
  30. '   with the Friend keyword can accept and
  31. '   return a UDT.
  32. Friend Property Get Demo() As udtDEMO
  33.     Demo = mDemo
  34. End Property
  35. ' Note that the argument of the Property
  36. '   Let must be ByRef for a UDT.
  37. Friend Property Let Demo(NewDemo As udtDEMO)
  38.     mDemo = NewDemo
  39. End Property
  40.  
  41. ' GetDemo and SetDemo show how Friend
  42. ' -------------------   functions can
  43. '   return UDTs, and how UDTs can be
  44. '   arguments of Friend procedures.
  45. Friend Function GetDemo() As udtDEMO
  46.     GetDemo = mDemo
  47. End Function
  48. ' Note that a UDT argument for a procedure
  49. '   must be declared ByRef.
  50. Friend Sub SetDemo(NewDemo As udtDEMO)
  51.     mDemo = NewDemo
  52. End Sub
  53.  
  54. ' SetDemoParts is a helper method that
  55. ' ------------      fills in the elements
  56. '   of the UDT, so there's something to
  57. '   pass.  In a real program, the elements
  58. '   of the UDT might be filled in by code
  59. '   in the TestClass object.
  60. Public Sub SetDemoParts(ByVal A As Integer, _
  61.         ByVal B As Long, ByVal C As String)
  62.     mDemo.intA = A
  63.     mDemo.lngB = B
  64.     mDemo.strC = C
  65. End Sub
  66.  
  67. ' ShowDemo displays the elements of the
  68. ' --------      UDT, so they can be viewed
  69. '   after the UDT is passed to the second
  70. '   object.
  71. Public Sub ShowDemo(ByVal Title As String, _
  72.         ByVal Direction As String)
  73.         
  74.     MsgBox Direction & "  " _
  75.         & GetDebugString(Me) & vbCrLf & vbCrLf _
  76.         & mDemo.intA & vbCrLf _
  77.         & mDemo.lngB & vbCrLf _
  78.         & mDemo.strC, , Title
  79. End Sub
  80.  
  81. Private Sub Class_Initialize()
  82.     mlngDebugID = DebugInit(Me)
  83. End Sub
  84.  
  85. Private Sub Class_Terminate()
  86.     DebugTerm Me
  87. End Sub
  88.  
  89. ' -------- IDebug Implementation --------
  90. '
  91. ' IDebug.DebugID gives you a way to tell
  92. ' ====== -------    objects apart.  It's
  93. '   required by the DebugInit, DebugTerm,
  94. '   and DebugShow debugging procedures
  95. '   declared in modFriend.
  96. '
  97. Private Property Get IDebug_DebugID() As Long
  98.     IDebug_DebugID = mlngDebugID
  99. End Property
  100.  
  101.