0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

演算処理

Last updated at Posted at 2025-04-23

演算処理

数値チェック

指定した変数が数値か否かをチェックする

'------------------------------------------------------------------------------
' 数値チェック
'------------------------------------------------------------------------------
Public Function F_CheckNumeric( _
        ByVal aCheck As Variant) As E_RET
    Dim wkRtn As E_RET: wkRtn = E_RET_NG
    
    If IsNull(aCheck) <> True Then
        Select Case VarType(aCheck)
            Case vbDecimal, vbByte, vbInteger, vbLong, vbLongLong
                wkRtn = E_RET_OK
            
            Case vbSingle, vbDouble, vbDate
                wkRtn = E_RET_OK_1
            
            Case vbString
                If IsNumeric(aCheck) = True Then
                    wkRtn = E_RET_OK_2
                End If
        End Select
    End If
    
    F_CheckNumeric = wkRtn
End Function

ビットチェック

数値の内で、指定したビットがONとなっているかをチェックする。
一部一致か完全一致の指定あり

'------------------------------------------------------------------------------
' ビットチェック
'------------------------------------------------------------------------------
Public Function F_CheckBitOn( _
        ByVal aNum As Long, ByVal aCheck As Long, _
        Optional ByVal aMask As Long = &H0, _
        Optional ByVal aChkSpec As E_CHECK = E_CHECK_OR) As Boolean
    Dim wkRet As Long
    Dim wkMask As Long
    
    If aChkSpec = E_CHECK_OR Then
        wkRet = ((aNum And aCheck) > 0)
    Else
        wkMask = aMask
        If wkMask = &H0 Then
            wkMask = aCheck
        End If
        
        wkRet = ((aNum And wkMask) = aCheck)
    End If
    
    F_CheckBitOn = wkRet
End Function
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?