⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 coutputlinksmanager.cls

📁 Data monkey是一个强大的是数据传输和转换应用程序。使用DataMonkey用户可以把复杂的文本文件格式
💻 CLS
字号:
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "COutputLinksManager"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Attribute VB_Ext_KEY = "SavedWithClassBuilder" ,"Yes"
Attribute VB_Ext_KEY = "Collection" ,"COutputLink"
Attribute VB_Ext_KEY = "Member0" ,"COutputLink"
Attribute VB_Ext_KEY = "Top_Level" ,"Yes"
Attribute VB_Ext_KEY = "SavedWithClassBuilder6" ,"Yes"
' DataMonkey Data Conversion Application. Written by Theodore L. Ward
' Copyright (C) 2002 AstroComma Incorporated.
'
' This program is free software; you can redistribute it and/or
' modify it under the terms of the GNU General Public License
' as published by the Free Software Foundation; either version 2
' of the License, or (at your option) any later version.
'
' This program is distributed in the hope that it will be useful,
' but WITHOUT ANY WARRANTY; without even the implied warranty of
' MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
' GNU General Public License for more details.
'
' You should have received a copy of the GNU General Public License
' along with this program; if not, write to the Free Software
' Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
' The author may be contacted at:
' TheodoreWard@Hotmail.com or TheodoreWard@Yahoo.com

'local variable to hold collection
Private mCol As Collection

Public Function ChangedDataItemName(oldName As String, _
                                newName As String) As Integer

    Dim ols As COutputLinks
    Dim ol As COutputLink
    ChangedDataItemName = 0
    
    ' Find all links for the old name and change the names.
    For Each ols In mCol
        Do
            Set ol = ols.GetLinkFrom(, oldName)
            If ol Is Nothing Then Exit Do
            ol.LinkFromField = newName
            Set ol = Nothing
            ChangedDataItemName = ChangedDataItemName + 1
        Loop While True
    Next ols
    
End Function

Public Function ChangedCheckPointName(oldName As String, _
                        newName As String) As Integer
    
    ' Check all the Output Links to make sure the links get updated
    ' with the new name for the checkpoint too.
    
    Dim ols As COutputLinks
    Dim ol As COutputLink
    
    ChangedCheckPointName = 0
    For Each ols In mCol
        Do
            Set ol = ols.GetLinkFrom(oldName)
            If ol Is Nothing Then Exit Do
            ol.LinkFromTable = newName
            Set ol = Nothing
            ChangedCheckPointName = ChangedCheckPointName + 1
        Loop While True
    Next ols

End Function

Public Function ChangedOutputFieldName(oldName As String, _
                                newName As String) As Integer

    Dim ols As COutputLinks
    Dim ol As COutputLink
    ChangedOutputFieldName = 0
    For Each ols In mCol
        Do
            Set ol = ols.GetLinkTo(, oldName)
            If ol Is Nothing Then Exit Do
            ol.LinkToField = newName
            Set ol = Nothing
            ChangedOutputFieldName = ChangedOutputFieldName + 1
        Loop While True
    Next ols
    
End Function

Public Function ChangedOutputTableName(oldName As String, _
                                newName As String) As Integer

    Dim ols As COutputLinks
    Dim ol As COutputLink
    ChangedOutputTableName = 0
    For Each ols In mCol
        Do
            Set ol = ols.GetLinkTo(oldName)
            If ol Is Nothing Then Exit Do
            ol.LinkToTable = newName
            Set ol = Nothing
            ChangedOutputTableName = ChangedOutputTableName + 1
        Loop While True
    Next ols

End Function

Public Function ItemByName(name As String) As COutputLinks
    On Error GoTo eHandler
    Set ItemByName = Nothing
    
    Dim ol As COutputLinks
    
    For Each ol In mCol
        If ol.name = name Then
            Set ItemByName = ol
            Set ol = Nothing
            Exit Function
        End If
    Next ol
    Exit Function
    
eHandler:
    LogError "COutputLinksManager", "ItemByName", Error(Err)
End Function

Public Property Get item(vntIndexKey As Variant) As COutputLinks
Attribute item.VB_UserMemId = 0
    'used when referencing an element in the collection
    'vntIndexKey contains either the Index or Key to the collection,
    'this is why it is declared as a Variant
    'Syntax: Set foo = x.Item(xyz) or Set foo = x.Item(5)
  Set item = mCol(vntIndexKey)
End Property

Public Property Get Count() As Long
    'used when retrieving the number of elements in the
    'collection. Syntax: Debug.Print x.Count
    Count = mCol.Count
End Property


Public Sub Remove(vntIndexKey As Variant)
    'used when removing an element from the collection
    'vntIndexKey contains either the Index or Key, which is why
    'it is declared as a Variant
    'Syntax: x.Remove(xyz)

    mCol.Remove vntIndexKey
End Sub


Public Property Get NewEnum() As IUnknown
Attribute NewEnum.VB_UserMemId = -4
Attribute NewEnum.VB_MemberFlags = "40"
    'this property allows you to enumerate
    'this collection with the For...Each syntax
    Set NewEnum = mCol.[_NewEnum]
End Property

Private Sub Class_Initialize()
    'creates the collection when this class is created
    Set mCol = New Collection
End Sub

Private Sub Class_Terminate()
    'destroys collection when this class is terminated
    Set mCol = Nothing
End Sub

Public Function Edit() As Boolean
        
    On Error GoTo eHandler
    
    Edit = False
    
    If mCol.Count > 0 Then
        frmIOMapping.SetLinksReference mCol(1)
    End If
    
    ' Give the mapping form a reference to the selected links object.
    frmIOMapping.Show vbModal
    
    Edit = True

    Exit Function
eHandler:
    LogError "COutputLinksManager", "Edit", Error(Err), False
End Function

Public Function AddObject(newItem As COutputLinks) As COutputLinks
    Set AddObject = Nothing
    On Error GoTo eHandler
    mCol.Add newItem, newItem.GetID
    Set addobejct = newItem
    Exit Function
eHandler:
    LogError "COuptutLinksManager", "AddObject", Error(Err), False
End Function

Public Function Add(Optional DefaultName As Boolean = False) As COutputLinks

    Set Add = Nothing
    On Error GoTo eHandler
    
    'create a new object
    Dim objNewMember As COutputLinks
    Set objNewMember = New COutputLinks
        
    If DefaultName Then
        Dim i As Integer
        Dim name As String
        Dim temp As COutputLinks
        Dim success As Boolean
        
        ' Default name for new data item.
        name = "New OutputLinks"

        ' Increment the number on the end of the name until
        ' we find a name that doesn't already exist.
        i = 0
        Do
            i = i + 1
            success = True
            For Each temp In mCol
                If temp.name = name + Trim(str(i)) Then
                    success = False
                    Exit For
                End If
            Next
        Loop While success = False
        
        ' Make the new name permanent.
        objNewMember.name = name + Trim(str(i))

    End If
    
    mCol.Add objNewMember, objNewMember.GetID

    'return the object created
    Set Add = objNewMember
    Set objNewMember = Nothing

    Exit Function

eHandler:
    LogError "COutputLinksManager", "Add", Error(Err)
    
    
End Function

Public Function Save(ByRef arc As CArchive) As Boolean
    On Error GoTo eHandler
    Save = False
    Dim ol As COutputLinks

    arc.SaveItem aiBEGINOUTPUTLINKSMANAGER
    For Each ol In mCol
        If Not ol.Save(arc) Then Exit Function
    Next ol
    arc.SaveItem aiENDITEM
    Save = True
    Exit Function

eHandler:
    LogError "COutputLinksManager", "Save", Error(Err)
End Function

Public Function Load(ByRef arc As CArchive) As Boolean
    On Error GoTo eHandler
    
    Load = False
    Dim i As Integer, retVal As Integer
    Dim value As Variant, item As String

    Do
        retVal = arc.GetNextItem(item, value)
    
        ' Error, log it, then exit with error.
        If retVal = ArcRetType.cERROR Then
            arc.AddError
            GoTo done
            
        ' We are done with this object, leave.
        ElseIf retVal = ArcRetType.cENDITEM Then
            Exit Do
        End If
        
        Select Case item
            Case "BEGIN OUTPUTLINKS"
                Add().Load arc
        End Select
    
    Loop While True

    Load = True
done:
    Exit Function

eHandler:
    LogError "COutputLinksManager", "Load", Error(Err)
End Function

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -