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

📄 ctips.cls

📁 VB精彩百例
💻 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 = "cTips"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False


    Option Explicit

' Private data members

' Define the collection of tips
    Private m_colTips As New Collection
    
Public Function Add(sText As String) As cTip
' Add a tip to the collection
' PropertiesL
' sText     string description of the tip
' Returns:
' tipNew    tip object
    Dim tipNew As New cTip
    Static iID As Integer
    With tipNew                     'generate a unique ID
        iID = iID + 1
        .ID = "T" & Format$(iID, "00000")
        .Text = sText               'set the properties
        m_colTips.Add tipNew, .ID   'add it to the collection
    End With
    Set Add = tipNew                'return the one that was added
End Function
Public Function Count() As Long
' Provide a count of the number in the collection
    Count = m_colTips.Count
End Function
Public Sub Delete(vKey As Variant)
' Delete the member from the collection.
' Parameters:
' vKey      key or index of member to delete
    m_colTips.Remove vKey           'delete it
End Sub
Public Function NextTip() As String
' Return the next tip
    Static iLast As Integer     'save last one
    iLast = iLast + 1
    If iLast > Me.Count Or iLast < 1 Then
        iLast = 1
    End If
    NextTip = m_colTips(iLast).Text & TipNumber(iLast)
End Function
Public Function RandomTip() As String
' Return a random description
    Dim iRandom As Integer
    Randomize                       'seed the random number generator
    iRandom = Int((Me.Count) * Rnd + 1) 'get a random number
    RandomTip = m_colTips(iRandom).Text & TipNumber(iRandom)    'return the random tip
End Function
Private Function TipNumber(iTheNumber As Integer) As String
' Add the number to the message
    TipNumber = Chr$(13) & Chr$(13) & "Tip " & iTheNumber
End Function
Private Sub Class_Initialize()
    ' Set several tips - "hard coded"
    Me.Add "Visual Basic精彩编程百例"
    Me.Add "实例25-类模块"
    Me.Add "每日一贴."
    Me.Add "感觉怎么样?呵呵"
End Sub

⌨️ 快捷键说明

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