IsNumeric, IsDate, IsNothing : String Functions « Data Type « VB.Net Tutorial






Public Class Tester
    Public Shared Sub Main
        Dim theData As String = Nothing
        Dim result As New System.Text.StringBuilder

        ' ----- Format nothing.
        result.AppendLine(String.Format( _
           "IsNumeric({0}) ... {1}", theData, IsNumeric(theData)))
        result.AppendLine(String.Format( _
           "IsDate({0}) ... {1}", theData, IsDate(theData)))
        result.AppendLine(String.Format( _
           "IsNothing({0}) ... {1}", theData, IsNothing(theData)))
        result.AppendLine()

        ' ----- Format a number in a string.
        theData = "-12.345"
        result.AppendLine(String.Format( _
           "IsNumeric({0}) ... {1}", theData, IsNumeric(theData)))
        result.AppendLine(String.Format( _
           "IsDate({0}) ... {1}", theData, IsDate(theData)))
        result.AppendLine(String.Format( _
           "IsNothing({0}) ... {1}", theData, IsNothing(theData)))
        result.AppendLine()

        ' ----- Format a date in a string.
        theData = "July 17, 2007"
        result.AppendLine(String.Format( _
           "IsNumeric({0}) ... {1}", theData, IsNumeric(theData)))
        result.AppendLine(String.Format( _
           "IsDate({0}) ... {1}", theData, IsDate(theData)))
        result.Append(String.Format( _
           "IsNothing({0}) ... {1}", theData, IsNothing(theData)))

        Console.WriteLine(result.ToString())

    End Sub
End Class
IsNumeric() ... False
IsDate() ... False
IsNothing() ... True

IsNumeric(-12.345) ... True
IsDate(-12.345) ... False
IsNothing(-12.345) ... False

IsNumeric(July 17, 2007) ... False
IsDate(July 17, 2007) ... True
IsNothing(July 17, 2007) ... False








2.38.String Functions
2.38.1.Passing String values to Val
2.38.2.Passing formatted numeric values to Val
2.38.3.IsNumeric, IsDate, IsNothing
2.38.4.Duplicate a string
2.38.5.Get string index by using InStr
2.38.6.CStr: Convert Double to String
2.38.7.Len: get string length
2.38.8.Instr
2.38.9.IsDBNull
2.38.10.Microsoft.VisualBasic.Left
2.38.11.String.Copy
2.38.12.Use String.Concat to concatenate two strings
2.38.13.Format: c
2.38.14.String handling function: Len
2.38.15.Left: get characters from left
2.38.16.Right: get characters from right
2.38.17.Mid(string, 4, 5): get sub string from middle
2.38.18.Mid(string, 7): get sub string from start
2.38.19.Instr: find character in a string
2.38.20.Instr: find sub string a in a string
2.38.21.LCase: change string to lower case
2.38.22.UCase: change string to upper case
2.38.23.Change string case using the English-United States and Turkish-Turkey cultures and then compare
2.38.24.Determines whether a string is normalized to various normalization forms(String.Normalize and the String.IsNormalized method)