Cette page vous a-t-elle été utile ?
Votre avis sur ce contenu est important. N'hésitez pas à nous faire part de vos commentaires.
Vous avez d'autres commentaires ?
1500 caractères restants
MSDN Library
EN
Ce contenu n’est pas disponible dans votre langue. Voici la version anglaise.

IsNumeric Function (Visual Basic) 

Returns a Boolean value indicating whether an expression can be evaluated as a number.


Public Function IsNumeric(ByVal Expression As Object) As Boolean

Parameters

Expression

Required. Object expression.

IsNumeric returns True if the data type of Expression is Boolean, Byte, Decimal, Double, Integer, Long, SByte, Short, Single, UInteger, ULong, or UShort. It also returns True if Expression is a Char, String, or Object that can be successfully converted to a number.

IsNumeric returns False if Expression is of data type Date. It returns False if Expression is a Char, String, or Object that cannot be successfully converted to a number.

The following example uses the IsNumeric function to determine if the contents of a variable can be evaluated as a number.

Dim testVar As Object
Dim numericCheck As Boolean
testVar = "53"
' The following call to IsNumeric returns True.
numericCheck = IsNumeric(testVar)
testVar = "459.95"
' The following call to IsNumeric returns True.
numericCheck = IsNumeric(testVar)
testVar = "45 Help"
' The following call to IsNumeric returns False.
numericCheck = IsNumeric(testVar)

Namespace: Microsoft.VisualBasic

Module: Information

Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)

Afficher:
© 2015 Microsoft