'********************************************************************************************************** ' Name: isDigit ' Author: mielk | 2012-02-19 ' ' Comment: Function checks if the given character is a digit. ' ' Parameters: ' char The character to be checked. ' The given text should contain only one character. If longer string is passed to ' this function, only first character is analyzed and the other ones are ignored. ' ' Returns: ' Boolean True - if the given character is a digit. ' False - if the given character is not a digit. ' ' ' --- Changes log ----------------------------------------------------------------------------------------- ' 2012-02-19 mielk Method created. '********************************************************************************************************** Public Function isDigit(ByVal char As String) As Boolean Const METHOD_NAME As String = "isDigit" '------------------------------------------------------------------------------------------------------ Dim iAsciiCode As Integer '------------------------------------------------------------------------------------------------------ 'Uses [Asc] function to get an ASCII code of a character. iAsciiCode = VBA.Asc(char) 'The ASCII codes for the digits range from 48 to 57. If an ASCII code of the character is 'within this range, the character is a digit and will be appended to the result string. If iAsciiCode >= 48 And iAsciiCode <= 57 Then isDigit = True End If End Function