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

📄 constructors.cls

📁 VB 加密----------能够加密解密控件
💻 CLS
📖 第 1 页 / 共 5 页
字号:
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "Constructors"
Attribute VB_GlobalNameSpace = True
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = True
'    CopyRight (c) 2004 Kelly Ethridge
'
'    This file is part of VBCorLib.
'
'    VBCorLib is free software; you can redistribute it and/or modify
'    it under the terms of the GNU Library General Public License as published by
'    the Free Software Foundation; either version 2.1 of the License, or
'    (at your option) any later version.
'
'    VBCorLib 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 Library General Public License for more details.
'
'    You should have received a copy of the GNU Library General Public License
'    along with Foobar; if not, write to the Free Software
'    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
'
'    Module: Constructors
'

''
' Functions used to create fully inititalized objects.
'
' @remarks
' This class is defined as Global-Multiuse. All of the functions can be called
' directly without needing to create a <b>Constructors</b> object.
' <p>The <b>Cor</b> static object can be used to easily find and select the
' desired object to create. By using the <b>Cor.NewXxx</b> method, the
' IntelliSense will show all of the available constructors, making object
' creation easier.</p>
' <p><h4>Example</h4>
' <pre>
' '' This calls the constructor function directly.
' Set fs = NewFileStream("data.txt", FileMode.OpenOrCreate)
'
' '' This calls the constructor through the Cor.NewXxx method.
' Set fs = Cor.NewFileStream("data.txt", FileMode.OpenOrCreate)
' </pre>
' Both methods perform the same task, however, using the Cor.Newxxx method
' will provide IntelliSense showing all of the available constructors.
'
Option Explicit

''
' Creates a For..Each compatible wrapper around an IEnumerator object.
'
' @param obj The IEnumerator object that is to be called during For..Each.
' @return A For..Each compatible enumerator.
' @remarks <p><b>VBCorLib</b> allows for the building of custom enumerators to be used
' in a For..Each loop context.</p>
' <p>To create a custom enumerator please refer to the IEnumerator interface.</p>
' <p>In order for VB to utilize your custom IEnumerator object, it must be
' wrapped in an object that implements the IEnumVariant interface. This is the
' only interface that VB can use in a For..Each context. By passing in the
' custom enumerator into the <b>CreateEnumerator</b> function, a wrapper is applied and returned that
' is then returned in the typical NewEnum function of a class.
' <h4>Example</h4>
' <pre>
' Public Function NewEnum() As IUnknown
'     Dim en As New MyEnumerator
'     en.Init Me
'     Set NewEnum = CreateEnumerator(en)
' End Sub
' </pre>
' This example creates a custom enumerator object and initializes it with
' the object that is to be enumerated using the custom enumerator. The
' custom enumerator is then passed into the CreateEnumerator function and the
' returned value is then passed back to the calling function.
'
' @see IEnumerator
'
Public Function CreateEnumerator(ByVal Obj As IEnumerator) As IUnknown
    Set CreateEnumerator = modIEnumerator.CreateEnumerator(Obj)
End Function

''
' Creates a new Exception object.
'
' @param Message A human-readable message explaining the exception.
' @param InnerException An exception that caused this exception.
' @return The fully created Exception object.
' @see Exception
'
Public Function NewException(ByVal Message As String, Optional ByVal InnerException As Exception) As Exception
    Set NewException = New Exception
    Call NewException.Init(Message, InnerException)
End Function

''
' Creates a new SystemException object.
'
' @param Message A human-readable message explaining the exception.
' @param InnerException An exception that caused this exception.
' @return A fully created SystemException object.
' @see SystemException
' @see Exception
'
Public Function NewSystemException(ByVal Message As String, Optional ByVal InnerException As Exception) As SystemException
    Set NewSystemException = New SystemException
    Call NewSystemException.Init(Message, InnerException)
End Function

''
' Creates a new UnauthorizedAccessException object.
'
' @param Message A human-readable message explaining the exception.
' @param InnerException An exception that caused this exception.
' @return A fully created UnauthorizedAccessException object.
'
Public Function NewUnauthorizedAccessException(ByVal Message As String, Optional ByVal InnerException As Exception) As UnauthorizedAccessException
    Set NewUnauthorizedAccessException = New UnauthorizedAccessException
    Call NewUnauthorizedAccessException.Init(Message, InnerException)
End Function

''
' Creates a new NotSupportedException object.
'
' @param Message A human-readable message explaining the exception.
' @param InnerException An exception that caused this exception.
' @return A fully created NotSupportedException object.
'
Public Function NewNotSupportedException(ByVal Message As String, Optional ByVal InnerException As Exception) As NotSupportedException
    Set NewNotSupportedException = New NotSupportedException
    Call NewNotSupportedException.Init(Message, InnerException)
End Function

''
' Creates a new ArgumentException object.
'
' @param Message A human-readable message explaining the exception.
' @param ParamName The parameter that caused the exception.
' @param InnerException An exception that caused this exception.
' @return A fully created <b>ArgumentException</b> object.
' @remarks
' <p>When throwing an <b>ArgumentException</b> a meaningful error message describing the invalid argument, the name
' of the argument, as well as the expected range of values for the argument should be defined.</p>
' <h4>Example</h4>
' <p><pre>
' '' Throws a default ArgumentException object
' Throw New ArgumentException
'
' '' Throws an ArgumentException with a custom message and parameter name
' Throw Cor.NewArgumentException("Your argument is wrong.", "MyParam")
'
' '' Throws an ArgumentException with a custom message and error code and parameter name
' Dim ex As ArgumentException
' Set ex = Cor.NewArgumentException("Your argument is wrong.", "MyParam")
' ex.HResult = 123
' Throw ex
' </pre></p>
' This example shows how to throw three different variations of the same <b>ArgumentException</b> object.
'
' @see ArgumentException
'
Public Function NewArgumentException(ByVal Message As String, Optional ByVal ParamName As String, Optional ByVal InnerException As Exception) As ArgumentException
    Set NewArgumentException = New ArgumentException
    Call NewArgumentException.Init(Message, ParamName, InnerException)
End Function

''
' Creates a new ArgumentNullException object.
'
' @param Message A human-readable message explaining the exception.
' @param ParamName The parameter that caused the exception.
' @param InnerException An exception that caused this exception.
' @return A fully created ArgumentNullException object.
' @remarks
' <p>When throwing an <b>ArgumentNullException</b> a meaningful error message describing the invalid argument
' and the name of the argument should be defined.</p>
' <h4>Example</h4>
' <p><pre>
' '' Throws a default ArgumentNullException object
' Throw New ArgumentNullException
'
' '' Throws an ArgumentNullException with a custom message and parameter name
' Throw Cor.NewArgumentNullException("A valid object is required.", "MyParam")
'
' '' Throws an ArgumentNullException with a custom message and error code and parameter name
' Dim ex As ArgumentNullException
' Set ex = Cor.NewArgumentNullException("A valid object is required.", "MyParam")
' ex.HResult = 123
' Throw ex
' </pre></p>
' This example shows how to throw three different variations of the same <b>ArgumentNullException</b> object.
'
' @see ArgumentNullException
'
Public Function NewArgumentNullException(ByVal Message As String, Optional ByVal ParamName As String, Optional ByVal InnerException As Exception) As ArgumentNullException
    Set NewArgumentNullException = New ArgumentNullException
    Call NewArgumentNullException.Init(Message, ParamName, InnerException)
End Function

''
' Creates a new ArgumentOutOfRangeException object.
'
' @param Message A human-readable message explaining the exception.
' @param ParamName The parameter that caused the exception.
' @param ActualValue The value of the parameter that caused the exception.
' @param InnerException An exception that caused this exception.
' @return A fully created AgrumentOutOfRangeException object.
' @see ArgumentOutOfRangeException
'
Public Function NewArgumentOutOfRangeException(Optional ByVal Message As String, Optional ByVal ParamName As String, Optional ByVal ActualValue As Variant, Optional ByVal InnerException As Exception) As ArgumentOutOfRangeException
    Set NewArgumentOutOfRangeException = New ArgumentOutOfRangeException
    Call NewArgumentOutOfRangeException.Init(Message, ParamName, ActualValue, InnerException)
End Function

''
' Creates a new InvalidCaseException object.
'
' @param Message A human-readable message explaining the exception.
' @param InnerException An exception that caused this exception.
' @return A fully created InvalidCastException object.
'
Public Function NewInvalidCastException(ByVal Message As String, Optional ByVal InnerException As Exception) As InvalidCastException
    Set NewInvalidCastException = New InvalidCastException
    Call NewInvalidCastException.Init(Message, InnerException)
End Function

''
' Creates a new IndexOutOfRangeException object.
'
' @param Message A human-readable message explaining the exception.
' @param InnerException An exception that caused this exception.
' @return A fully created IndexOutOfRangeException object.
'
Public Function NewIndexOutOfRangeException(ByVal Message As String, Optional ByVal InnerException As Exception) As IndexOutOfRangeException
    Set NewIndexOutOfRangeException = New IndexOutOfRangeException
    Call NewIndexOutOfRangeException.Init(Message, InnerException)
End Function

''
' Creates a new RankException object.
'
' @param Message A human-readable message explaining the exception.
' @param InnerException An exception that caused this exception.
' @return A fully created RankException object.
'
Public Function NewRankException(ByVal Message As String, Optional ByVal InnerException As Exception) As RankException
    Set NewRankException = New RankException
    Call NewRankException.Init(Message, InnerException)
End Function

''
' Creates a new InvalidOperationException object.
'
' @param Message A human-readable message explaining the exception.
' @param InnerException An exception that caused this exception.
' @return A fully created InvalidOperationException object.
'
Public Function NewInvalidOperationException(ByVal Message As String, Optional ByVal InnerException As Exception) As InvalidOperationException
    Set NewInvalidOperationException = New InvalidOperationException
    Call NewInvalidOperationException.Init(Message, InnerException)
End Function

''
' Creates a new ArrayList object with the specified settings.
'
' @param comparer A comparer to be used for searching and sorting items in the list.
' @param c A collection to initialize the list with. Count will reflect the number of items added.
' @return A new ArrayList object.
' @remarks Sometimes the comparison of two items in the list cannot be accomplished
' by the default comparer that <b>ArrayList</b> uses. Cases like this may be when using
' different datatypes, UDT's, or objects that do not implement <b>IComparable</b>. In
' cases such as these, a custom comparer object may be supplied during the construction
' of an <b>ArrayList</b>. This comparer will be used as the default comparer for methods
' that require comparing items.
' <p>An <b>ArrayList</b> can be initialized with a default set of items. This is the same
' as creating a new <b>ArrayList</b> and using AddRange to add the items.</p>
' <p><b>ArrayList</b> accepts a VBA.Collection, ICollection, and an array as a list of
' items to initialize the new <b>ArrayList</b> to.
'
' <h4>Example</h4>
' <pre>
' Dim MyItems(10) As Long
'
' Set list = NewArrayList(New MyComparer, MyItems)
' </pre>
' This will create a new <b>ArrayList</b> that uses MyComparer as the default comparer
' for the items. The <b>ArrayList</b> is also initialized with an array of Longs. The
' fully initialized <b>ArrayList</b> will have a Count of 11 items, each item being
' a Long datatype with the value of 0.
'
' @see ArrayList
' @see IComparer
'

⌨️ 快捷键说明

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