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

📄 coutputtargetfields.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 = "COutputTargetFields"
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" ,"COutputTargetField"
Attribute VB_Ext_KEY = "Member0" ,"COutputTargetField"
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
Option Compare Text

Public Function Copy() As COutputTargetFields
    On Error GoTo eHandler
    Set Copy = Nothing

    Dim newObj As COutputTargetFields
    Set newObj = New COutputTargetFields
    Dim obj As COutputTargetField
    
    ' Copy all the objects.
    For Each obj In mCol
        newObj.AddObject obj.Copy
    Next obj
    
    Set Copy = newObj
    Set newObj = Nothing
    Exit Function

eHandler:
    LogError "COutputTargetFields", "Copy", Error(Err), False

End Function

Public Function ItemByName(itemName As String) As COutputTargetField
    On Error GoTo eHandler
    Set ItemByName = Nothing
    
    Dim of As COutputTargetField
    
    ' Find the output target with the matching name.
    For Each of In mCol
        If of.name = itemName Then
            Set ItemByName = of
            Set of = Nothing
            Exit Function
        End If
    Next of
    
    Exit Function
    
eHandler:
    LogError "COutputTargetFields", "ItemByName", Error(Err)
    
End Function

Public Function AddObject(newItem As COutputTargetField) As COutputTargetField

    Set AddObject = Nothing
    newItem.index = mCol.Count + 1
    mCol.Add newItem, newItem.GetID
    Set AddObject = newItem

End Function

Public Function Add(Optional DefaultName As Boolean = False) As COutputTargetField
    Set Add = Nothing
    On Error GoTo eHandler
    
    'create a new object
    Dim objNewMember As COutputTargetField
    Set objNewMember = New COutputTargetField
        
    If DefaultName Then
        Dim i As Integer
        Dim name As String
        Dim temp As COutputTargetField
        Dim success As Boolean
        
        ' Default name for new data item.
        name = "New Field"

        ' 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
    
    objNewMember.index = mCol.Count + 1
    mCol.Add objNewMember, objNewMember.GetID

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

    Exit Function

eHandler:
    LogError "COutputTargetFields", "Add", Error(Err)
    

End Function

Public Function Save(arc As CArchive) As Boolean
    On Error GoTo eHandler
    Save = False
    Dim ot As COutputTargetField
    
    For Each ot In mCol
        If Not ot.Save(arc) Then Exit Function
    Next ot
    Save = True
    Exit Function

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

Public Property Get item(vntIndexKey As Variant) As COutputTargetField
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

⌨️ 快捷键说明

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