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

📄 cactions.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 = "CActions"
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" ,"CAction"
Attribute VB_Ext_KEY = "Member0" ,"CAction"
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

Option Explicit

'local variable to hold collection
Private mCol As Collection

Public Function InsertActionObject(newObj As Object, insertAt As Integer) As CInputRecord
    On Error GoTo eHandler
    Dim i As Integer
    Set InsertActionObject = Nothing
    
    If newObj Is Nothing Then Exit Function
    
    newObj.index = insertAt

    If insertAt > mCol.Count Then
        ' Insert as last item.
        newObj.index = insertAt
        mCol.Add newObj, newObj.GetID
    Else
        ' Insert the item into our collection before the item that
        ' currently occupies the position indicated.
        mCol.Add newObj, newObj.GetID, mCol(insertAt).GetID
        
        For i = mCol.Count To insertAt + 1 Step -1
            mCol(i).index = i
        Next i
    End If
    
    Set InsertActionObject = newObj
    Exit Function
eHandler:

End Function

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

    Dim newObj As CActions
    Set newObj = New CActions
    Dim obj As Object
    
    For Each obj In mCol
        newObj.AddObject obj.Copy
    Next obj
    
    Set Copy = newObj
    Set newObj = Nothing
    Exit Function

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

End Function

Public Function AddNew(CmdType As eCmdTypes) As Object

    On Error GoTo eHandler
    Set AddNew = Nothing
    
    Dim act As Object
    Dim i As Integer
    
    Select Case CmdType
        Case eCmdTypes.cmdif
            Set act = New CCmdIf
        Case eCmdTypes.cmdExecute
            Set act = New CCmdExecute
        Case eCmdTypes.cmdGetValue
            Set act = New CCmdGetValue
        Case eCmdTypes.cmdConvertData
            Set act = New CCmdConvertData
        Case eCmdTypes.cmdSkipLines
            Set act = New CCmdSkipLines
        Case eCmdTypes.cmdLookup
            Set act = New CCmdLookup
        Case eCmdTypes.cmdGetFieldValue
            Set act = New CCmdGetFieldValue
        Case eCmdTypes.cmdReadConstantValue
            Set act = New CCmdReadConstantValue
        Case eCmdTypes.cmdCalculateValue
            Set act = New CCmdCalculateValue
        Case Else
            LogError "CActions", "Add(eCmdTypes)", "Invalid Paramater=" & CStr(CmdType)
            Exit Function
    End Select
    
    '*****************************
    ' Find the next available key.
    '*****************************
    
    act.index = mCol.Count
    
    mCol.Add item:=act, key:=act.GetID
    Set AddNew = act
    Set act = Nothing
    Exit Function
    
eHandler:
    LogError "CActions", "AddNew", Error(Err)
    
Exit Function
End Function

Public Sub Reorder()

    Dim temp As Collection
    Dim i As Integer
    
    Set temp = mCol
    Set mCol = Nothing
    Set mCol = New Collection
    
    i = 0
    Do While temp.Count > 0
        Dim obj As Object
        Dim j As Integer
        Dim smallest As Integer
            
        i = i + 1       'Incremement the new index.
        
        '***************************************
        ' Find the object with the lowest index.
        '***************************************
        
        smallest = 1
        For j = 1 To temp.Count
            If temp(j).index < temp(smallest).index Then
                smallest = j
            End If
        Next j
        
        Set obj = temp(smallest)
        obj.index = i
        mCol.Add item:=obj, key:=obj.GetID
        temp.Remove obj.GetID
        Set obj = Nothing
    Loop

End Sub

Public Function AddObject(cmd As Object) As Object
    On Error GoTo eHandler
    
    mCol.Add item:=cmd, key:=cmd.GetID
    Set AddObject = cmd
    Exit Function
    
eHandler:
    LogError "CActions", "AddObject", Error(Err)
    
End Function

Public Property Get item(vntIndexKey As Variant) As Object
Attribute item.VB_UserMemId = 0
    On Error Resume Next
    '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(index As Variant)

    On Error GoTo eHandler
    
    mCol.Remove index

    Exit Sub
    
eHandler:
'    LogError "CActions", "Remove", Error(Err), False
'
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 Save(arc As CArchive) As Boolean
    
    On Error GoTo eHandler
    Save = False
    
    Dim act As Object
    For Each act In mCol
        If act.Save(arc) = False Then Exit Function
        Set act = Nothing
        arc.SaveItem aiBLANKLINE
    Next

    Save = True
    Exit Function
    
eHandler:
    LogError "CActions", "Save", Error(Err)
    
End Function

⌨️ 快捷键说明

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