messages.cls

来自「金算盘软件代码」· CLS 代码 · 共 65 行

CLS
65
字号
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
END
Attribute VB_Name = "Messages"
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 = "Top_Level" ,"Yes"
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
'
'  主控消息集合类
'  作者:黄涛
'  日期:1998.02.21
'
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''

Option Explicit

Private mcolMessages As New Collection

'  添加方法,在集合中创建一个新消息
Public Function Add(ByVal msgMessage As Message)
    On Error Resume Next
    mcolMessages.Add msgMessage, CStr(msgMessage)
End Function

' 返回集合中按照参数vntIndex指定的元素
Public Property Get Item(vntIndex As Variant) As MainControl
Attribute Item.VB_UserMemId = 0
    '参数vntIndexKey可以是集合元素的索引或关键字
    Set Item = mcolMessages(vntIndex)
End Property

' 返回集合中元素数目
Public Function Count() As Long
    Count = mcolMessages.Count
End Function


'删除集合中按照参数vntIndex指定的元素
Public Sub Remove(vntIndex As Variant)
    mcolMessages.Remove vntIndex
End Sub

'清除集合中所有元素
Public Sub Clear()
    Dim lngCnt As Long
    
    For lngCnt = 1 To mcolMessages.Count
        mcolMessages.Remove 1
    Next
End Sub

Public Function NewEnum() As IUnknown
Attribute NewEnum.VB_UserMemId = -4
Attribute NewEnum.VB_MemberFlags = "40"
    '本属性允许用 For...Each 语法枚举该集合。
    Set NewEnum = mcolMessages.[_NewEnum]
End Function


⌨️ 快捷键说明

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