VBA

データ型変換クラス

''' <summary>
''' データ型変換関数
''' </summary>
''' <see>https://learn.microsoft.com/ja-jp/office/vba/language/concepts/getting-started/type-conversion-functions</see>

CBool

''' <summary>
''' データ型変換関数(Boolean)
''' </summary>
''' <param name="Expression">値</param>
''' <reterns>ブール型</reterns>
Public Function CnBool(ByVal Expression As Object) As Boolean
    CnBool = CBool(Expression)
End Function

CByte

''' <summary>
''' データ型変換関数(Byte)
''' </summary>
''' <param name="Expression">値</param>
''' <reterns>バイト型</reterns>
Public Function CnByte(ByVal Expression As Object) As Byte
    CnByte = CByte(Expression)
End Function

CCur

''' <summary>
''' データ型変換関数(Currency)
''' </summary>
''' <param name="Expression">値</param>
''' <reterns>通貨型</reterns>
Public Function CnCur(ByVal Expression As Object) As Currency
    CnCur = CCur(Expression)
End Function

CDate

''' <summary>
''' データ型変換関数(Date)
''' </summary>
''' <param name="Expression">値</param>
''' <reterns>日付型</reterns>
Public Function CnDate(ByVal Expression As Object) As Date
    CnDate = CDate(Expression)
End Function

CDbl

''' <summary>
''' データ型変換関数(Double)
''' </summary>
''' <param name="Expression">値</param>
''' <reterns>倍精度浮動小数点数型</reterns>
Public Function CnDbl(ByVal Expression As Object) As Double
    CnDbl = CDbl(Expression)
End Function

CDec

'''' <summary>
'''' データ型変換関数(Decimal)
'''' </summary>
'''' <param name="Expression">値</param>
'''' <reterns>戻り値</reterns>
'''' <remarks>Excel VBAでは無効</remarks>
'Public Function CnDec(ByVal Expression As Object) As Decimal
'    CnDec = CDec(Expression)
'End Function

CInt

''' <summary>
''' データ型変換関数(Integer)
''' </summary>
''' <param name="Expression">値</param>
''' <reterns>整数型</reterns>
Public Function CnInt(ByVal Expression As Object) As Integer
    CnInt = CInt(Expression)
End Function

CLng

''' <summary>
''' データ型変換関数(Long)
''' </summary>
''' <param name="Expression">値</param>
''' <reterns>長整数型</reterns>
Public Function CnLng(ByVal Expression As Object) As Long
    CnLng = CLng(Expression)
End Function
''' <summary>
''' データ型変換関数(LongLong)
''' </summary>
''' <param name="Expression">値</param>
''' <reterns>戻り値</reterns>
''' <remarks>64 ビットのプラットフォームでのみ有効</remarks>
Public Function CnLngLng(ByVal Expression As Object) As LongLong
    CnLngLng = CLngLng(Expression)
End Function
''' <summary>
''' データ型変換関数(LongPtr)
''' </summary>
''' <param name="Expression">値</param>
''' <reterns>戻り値</reterns>
Public Function CnLngPtr(ByVal Expression As Object) As LongPtr
    CnLngPtr = CLngPtr(Expression)
End Function

CSng

''' <summary>
''' データ型変換関数(Single)
''' </summary>
''' <param name="Expression">値</param>
''' <reterns>単精度浮動小数点数型</reterns>
Public Function CnSng(ByVal Expression As Object) As Single
    CnSng = CSng(Expression)
End Function

CStr

''' <summary>
''' データ型変換関数(String)
''' </summary>
''' <param name="Expression">値</param>
''' <reterns>文字列型</reterns>
Public Function CnStr(ByVal Expression As Object) As String
    CnStr = CStr(Expression)
End Function

CVar

''' <summary>
''' データ型変換関数(Variant)
''' </summary>
''' <param name="Expression">値</param>
''' <reterns>バリアント型</reterns>
Public Function CnVar(ByVal Expression As Object) As Variant
    CnVar = CVar(Expression)
End Function

コメント