桁数チェック

3月 17th, 2011

DBとかでちょいちょい使うので。
小数には対応してません

    ''' <summary>
    ''' 桁数チェック
    ''' </summary>
    ''' <param name="value">値</param>
    ''' <param name="digits">桁</param>
    ''' <returns>true:OK false:NG</returns>
    Public Function CheckIntDigits(ByVal value As Integer, ByVal digits As Byte) As Boolean
        Dim c As Integer = CInt(10 ^ digits)
        If value < 0 Then
            value *= -1
        End If

        Return IIf(value >= c, False, True)
    End Function

Posted in ProgramingNo Comments

Leave a Comment