home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic 4 Power Pack / Visual_Basic4_Power_Pack.bin / vb4files / dbawarco / phone.cls < prev    next >
Encoding:
Text File  |  1996-11-20  |  2.2 KB  |  88 lines

  1. VERSION 1.0 CLASS
  2. BEGIN
  3.   MultiUse = -1  'True
  4. END
  5. Attribute VB_Name = "Phone"
  6. Attribute VB_Creatable = False
  7. Attribute VB_Exposed = True
  8. Option Explicit
  9.  
  10. Public PhoneNumber As String
  11. Public Usage As String
  12. Public ObjectID As Long
  13.  
  14. Public Function FormattedPhoneNumber() As String
  15. ' Return a displayable, fully formatted
  16. '   version of Me
  17.  
  18.     If Len(PhoneNumber) <= 7 Then
  19.         FormattedPhoneNumber = Format$(PhoneNumber, "000-0000")
  20.     ElseIf Len(PhoneNumber) <= 10 Then
  21.         FormattedPhoneNumber = Format$(PhoneNumber, "(000) 000-0000")
  22.     ElseIf Len(PhoneNumber) = 11 Then
  23.         FormattedPhoneNumber = Format$(PhoneNumber, "0 (000) 000-0000")
  24.     Else
  25.         FormattedPhoneNumber = PhoneNumber
  26.     End If
  27.  
  28. End Function
  29.  
  30.  
  31. Public Function InitializeFromRecordSet(Optional ByVal RecordSet As Variant) As Phone
  32. ' Populate my variables from the RecordSet
  33. '   (in support of DBAwareCollection)
  34.  
  35.     On Local Error Resume Next
  36.     
  37.     PhoneNumber = RecordSet("PhoneNumber")
  38.     Usage = RecordSet("Usage")
  39.     ObjectID = RecordSet("ObjectID")
  40.  
  41.     Set InitializeFromRecordSet = Me
  42. End Function
  43.  
  44.  
  45. Public Function InitializeRecordSet(Optional ByVal RecordSet As Variant) As Long
  46. ' Populate the RecordSet with my variables.
  47. '   Do not initialize the ObjectID column.
  48. '   Return any error code encountered.
  49. '   (in support of DBAwareCollection)
  50.  
  51.     On Local Error GoTo InitializeRecordSet_SetError
  52.     Err = 0
  53.     
  54.     RecordSet("PhoneNumber") = PhoneNumber
  55.     RecordSet("Usage") = Usage
  56.     
  57.     GoTo InitializeRecordSet_SetError
  58.  
  59. InitializeRecordSet_SetError:
  60.     InitializeRecordSet = Err
  61.     Exit Function
  62. End Function
  63.  
  64.  
  65. Public Function NewInstanceOfMyClass() As Phone
  66. ' Return a new instance of this class
  67. '   (in support of DBAwareCollection)
  68.  
  69.     Set NewInstanceOfMyClass = New Phone
  70. End Function
  71.  
  72.  
  73. Public Function ObjectType() As String
  74. ' Return the type of this Class
  75. '   (in support of DBAwareCollection)
  76.     
  77.     ObjectType = "Phone"
  78. End Function
  79.  
  80.  
  81. Public Function TableName() As String
  82. ' Return the Table with which this Class is associated
  83. '   (in support of DBAwareCollection)
  84.     
  85.     TableName = "Phones"
  86. End Function
  87.  
  88.