home *** CD-ROM | disk | FTP | other *** search
- VERSION 1.0 CLASS
- BEGIN
- MultiUse = -1 'True
- END
- Attribute VB_Name = "Phone"
- Attribute VB_Creatable = False
- Attribute VB_Exposed = True
- Option Explicit
-
- ' the following pertain to being supported by
- ' VBOFCollection, VBOFObjectManager and
- ' VBOFEventManager
- Public ObjectID As Long
- Public ObjectChanged As Long
- Public ObjectAdded As Long
- Public ObjectDeleted As Long
- Public ObjectParentCount As Long
- Public ObjectManager As VBOFObjectManager
-
- ' the following code pertains to the business
- ' of the Phone object
- Private pvtPhoneNumber As String
- Private pvtUsage As String
-
- Public Function ObjectDBGridUnboundReadData(Optional DBGrid As Variant, Optional RowBuf As Variant, Optional RowNumber As Variant) As Boolean
- ' Populate the DBGrid RowBuf with values from
- ' variables within this object
- ' (in support of VBOFCollection)
- ' Parameter Description:
- ' DBGrid:= the DBGrid which is being
- ' populated
- ' RowBuf:= the current DBGrid RowBuf object
- ' RowNumber:= the row number being processed
-
- Dim I As Long
-
- For I = 0 To RowBuf.ColumnCount - 1
- Select Case RowBuf.ColumnName(I)
- Case "PhoneNumber"
- RowBuf.Value(RowNumber, I) = PhoneNumber
- Case "Usage"
- RowBuf.Value(RowNumber, I) = Usage
- Case "ObjectID"
- RowBuf.Value(RowNumber, I) = ObjectID
- End Select
- Next I
-
- End Function
-
- Public Function ObjectDBGridUnboundAddData(Optional DBGrid As Variant, Optional RowBuf As Variant, Optional NewRowBookmark As Variant) As Boolean
- ' Populate the object variables with the values
- ' provided by the user in the new row of the
- ' DBGrid
- ' (in support of VBOFCollection)
- '
- ' Parameter Description:
- ' DBGrid:= the DBGrid which is being
- ' populated
- ' RowBuf:= the current DBGrid RowBuf object
- ' NewRowBookmark:= the row number being processed
-
- Dim I As Long
-
- For I = 0 To RowBuf.ColumnCount - 1
- If Not IsNull(RowBuf.Value(0, I)) Then
- Select Case RowBuf.ColumnName(I)
- Case "PhoneNumber"
- PhoneNumber = RowBuf.Value(0, I)
- Case "Usage"
- Usage = RowBuf.Value(0, I)
-
- ' Note: Do not initialize the ObjectID.
-
- End Select
- End If
- Next I
-
- ' return "OK" status
- ObjectDBGridUnboundAddData = True
- End Function
-
-
- Public Function ObjectListBoxValue() As String
- ' Return a String will represent this object
- ' in a ListBox
- ' (in support of VBOFCollection)
-
- ObjectListBoxValue = _
- FormattedPhoneNumber
-
- End Function
-
-
- Private Sub Class_Terminate()
- If Not ObjectManager Is Nothing Then
- ObjectManager.TerminateObject _
- Object:=Me
- End If
- End Sub
-
-
-
- Public Function ObjectHasChanged()
- ' Mark this object as "Changed" and trigger the
- ' "Changed" event
-
- ObjectChanged = True
-
- #If NoEventMgr = False Then
- If Not ObjectManager Is Nothing Then
- ObjectManager. _
- TriggerObjectEvent _
- Event:="Changed", _
- Object:=Me
- End If
- #End If
-
- End Function
-
- Public Function FormattedPhoneNumber() As String
- ' Return a displayable, fully formatted
- ' version of Me
-
- If Len(PhoneNumber) <= 7 Then
- FormattedPhoneNumber = Format$(PhoneNumber, "000-0000")
- ElseIf Len(PhoneNumber) <= 10 Then
- FormattedPhoneNumber = Format$(PhoneNumber, "(000) 000-0000")
- ElseIf Len(PhoneNumber) = 11 Then
- FormattedPhoneNumber = Format$(PhoneNumber, "0 (000) 000-0000")
- Else
- FormattedPhoneNumber = PhoneNumber
- End If
-
- End Function
-
-
- Public Function ObjectInitializeFromRecordSet(Optional RecordSet As Variant) As Phone
- ' Populate my variables from the RecordSet
- ' (in support of VBOFCollection)
-
- On Local Error Resume Next
-
- PhoneNumber = RecordSet("PhoneNumber")
- Usage = RecordSet("Usage")
-
- ObjectID = RecordSet("ObjectID")
-
- Set ObjectInitializeFromRecordSet = Me
- End Function
-
-
- Public Function ObjectInitializeRecordSet(Optional RecordSet As Variant) As Long
- ' Populate the RecordSet with my variables.
- ' Do not initialize the ObjectID column.
- ' Return any error code encountered.
- ' (in support of VBOFCollection)
-
- On Local Error GoTo InitializeRecordSet_SetError
- Err = 0
-
- RecordSet("PhoneNumber") = PhoneNumber
- RecordSet("Usage") = Usage
-
- ' Note: Do not initialize the ObjectID column.
-
- GoTo InitializeRecordSet_SetError
-
- InitializeRecordSet_SetError:
- ObjectInitializeRecordSet = Err
- Exit Function
- End Function
-
-
- Public Function ObjectNewInstanceOfMyClass() As Phone
- ' Return a new instance of this class
- ' (in support of VBOFCollection)
-
- Set ObjectNewInstanceOfMyClass = New Phone
- End Function
-
-
- Public Function ObjectEventCallBack(Optional Event As Variant, Optional Object As Variant) As Long
- ' Receive the Trigger notification and process
- ' accordingly
- '
- ' Parameters:
- ' Event
- ' a string which identifies the Event
- ' Example: "Changed", "Created", "Deleted"
- ' Object
- ' the object originating the Event.
- ' responds to:
- ' TypeName(TriggerObject)
- ' TriggerObject.ObjectID
- ' (supported by VBOFEventManager)
-
- End Function
-
-
-
-
-
- Public Function ObjectDataSource() As String
- ' Return the Data Source with which this Class is associated
- ' (in support of VBOFCollection)
-
- ObjectDataSource = "Phones"
- End Function
-
-
- Public Property Get PhoneNumber() As String
- PhoneNumber = pvtPhoneNumber
- End Property
-
- Public Property Let PhoneNumber(aString As String)
- pvtPhoneNumber = aString
- ' ObjectHasChanged
- End Property
-
- Public Property Get Usage() As String
- Usage = pvtUsage
- End Property
-
- Public Property Let Usage(aString As String)
- pvtUsage = aString
- ' ObjectHasChanged
- End Property
-