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

📄 argumentoutofrangeexception.cls

📁 VB 加密----------能够加密解密控件
💻 CLS
📖 第 1 页 / 共 2 页
字号:
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 1  'Persistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "ArgumentOutOfRangeException"
Attribute VB_GlobalNameSpace = False
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: ArgumentOutOfRangeException
'

''
' The exception that is thrown when the value of an argument is outside the
' allowable range of values as defined by the invoked method.
'
' @remarks
' <p><b>ArgumentOutOfRangeException</b> is thrown when an argument is not Null and
' is outside of the allowable range of values.</p>
' <p>An <b>ArgumentOutOfRangeException</b> works the same as an <b>ArgumentException</b>. It
' is used to distinguish between other argument exceptions and those that are out of a valid range.
'
' @see Constructors
' @see ExceptionMethods
' @see Exception
' @see ArgumentException
' @see SystemException
'
Option Explicit
Implements IObject
Implements Exception
Implements SystemException
Implements ArgumentException

Private Const PROP_PARAMNAME    As String = "ParamName"
Private Const PROP_ACTUALVALUE  As String = "ActualValue"
Private Const PROP_BASE         As String = "Base"
Private Const DEF_PARAMNAME     As String = vbNullString
Private Const DEF_ACTUALVALUE   As Variant = Empty
Private Const DEF_HRESULT       As Long = COR_E_ARGUMENTOUTOFRANGE

' This can do it all.
Private mBase As ExceptionBase


''
' Returns a key/value collection used to contain user-defined specific information about the exception.
'
' @return A key/value collection for user-defined information.
'
Public Property Get Data() As IDictionary
    Set Data = mBase.Data
End Property

''
' Returns the actual value that caused the exception to be thrown.
'
' @return A value of the parameter that caused the exception.
'
Public Property Get ActualValue() As Variant
    Call Helper.MoveVariant(ActualValue, mBase.GetValue(PROP_ACTUALVALUE, MissingVariant))
End Property


''
' Returns the parameter name that caused the exception.
'
' @return The name of the parameter that caused the exception.
' @remarks Every <b>ArgumentNullException</b> should contain the name
' of the parameter that caused the exception.
' @see Exception
'
Public Property Get ParamName() As String
    ParamName = mBase.GetValue(PROP_PARAMNAME, DEF_PARAMNAME)
End Property

''
' Gets a link to a help file associated with the exception.
'
' @return The Uniform Resource Name (URN) or Uniform Resource Locator (URL).
' @remarks The return value, which represents a help file, is a URN or URL. For example, the HelpLink value could be:<br>
' "http://www.myhelpsite.com"
'
Public Property Get HelpLink() As String
    HelpLink = mBase.HelpLink
End Property

''
' Sets a link to a help file associated with the exception.
'
' @param RHS Set the Uniform Resource Name (URN) or Uniform Resource Locator (URL).
' @remarks The return value, which represents a help file, is a URN or URL. For example, the HelpLink value could be:<br>
' "http://www.myhelpsite.com"
'
Public Property Let HelpLink(ByVal RHS As String)
    mBase.HelpLink = RHS
End Property

''
' Gets the HRESULT, a coded numerical value that is assigned to a specific exception.
'
' @return The value of the associated HResult.
' @remarks An HResult is associated with an error result code. This allows for VB specific
' error codes to be returned.
' @see Exception
'
Public Property Get HResult() As Long
    HResult = mBase.HResult
End Property

''
' Sets the HRESULT, a coded numerical value that is assigned to a specific exception.
'
' @param RHS The value of the associated HResult.
' @remarks An HResult is associated with an error result code. This allows for VB specific
' error codes to be returned. This is the same as <b>Err.Number</b>.
' @see Exception
'
Public Property Let HResult(ByVal RHS As Long)
    mBase.HResult = RHS
End Property

''
' Gets a description of the source of the exception.
'
' @return A description of the source of the exception.
' @remarks The source of an exception generally will contain the name of
' the function being called when the exception was thrown. This is to help
' narrow down exactly where the exception had occurred.
'
Public Property Get Source() As String
    Source = mBase.Source
End Property

''
' Sets a description of the source of the exception.
'
' @param RHS A description of the source of the exception.
' @remarks The source of an exception generally will contain the name of
' the function being called when the exception was thrown. This is to help
' narrow down exactly where the exception had occurred.
'
Public Property Let Source(ByVal RHS As String)
    mBase.Source = RHS
End Property

''
' Gets the error message associated with the Subclass exception.
'
' @return A custom message set by the Subclass, or a default
' message of "An Error has occurred."
' @remarks Generally this property is set to a meaningful message that
' is related to the exception that is being thrown. The message should
' be human readable.
' <p>This property can be set in the constructor <b>NewArgumentNullException</b>.
'
Public Property Get Message() As String
    Message = mBase.Message
    
    ' If there is a parameter name, add it to the message
    ' on a new line for everyone to see.
    Dim ParamName As String
    ParamName = Me.ParamName
    If Len(ParamName) > 0 Then Message = Message & vbCrLf & vbCrLf & "Parameter Name: " & ParamName
    
    ' Get a string representation of the actual value.
    Dim ActualValue As String
    ActualValue = Convert.ToString(Me.ActualValue)
    
    ' If we have an actual value, we want to append it to the
    ' end of the message on it's own line, if the message is not empty.
    If Not cString.IsNull(ActualValue) Then
        If Len(Message) > 0 Then Message = Message & vbCrLf
        Message = Message & "Actual Value: " & ActualValue
    End If
End Property

''
' Gets the exception that caused the Subclassed exception to be thrown.
'
' @return The inner exception that caused the current exception to be thrown.
' @remarks when an exception is thrown and that exception causes another
' exception to be thrown, then the <b>InnerException</b> of the new <b>Exception</b>
' object should contain the exception that caused it to be thrown.
'
Public Property Get InnerException() As Exception
    Set InnerException = mBase.InnerException
End Property

''
' Gets the original exception that caused the chain of exceptions to occur.
'
' @return The <b>Exception</b> that caused the chain of exceptions to occur.
' @remarks If exceptions set their <b>InnerException</b> to a previously thrown
' exception, then a chain of exceptions can be created. Using this function will
' traverse that chain of exceptions until the original exception is reached. That
' exception with then be returned to the caller.
' <p>When an <b>InnerException</b> of Nothing is reached, then then the exception object is returned
' as the base exception because it did not have an inner exception, so it is assumed that
' the exception object is the last in the chain and therefore the cause of the
' chain of exceptions being iterated.
'
Public Function GetBaseException() As Exception
    Set GetBaseException = mBase.GetBaseException
End Function

''
' Returns the exception message prepended with the type name of the Subclass Exception.
'
' @return A formatted message containing the original message and possible type of exception.
' @remarks A general format might look like this:<br>
' VBCorLib.SystemException: An Error has occurred.
' <p>A listing of all inner exceptions will be included in the return value.</p>
'
Public Function ToString() As String
    ToString = mBase.ToString(Message)
End Function

''

⌨️ 快捷键说明

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