「VB.NET」文字が区切り記号かどうかを判定するサンプル
構文
1.IsLetter(Char)
指定した Unicode 文字が Unicode 文字かどうかを示します。
2.IsPunctuation(Char)
指定した Unicode 文字が区切り記号かどうかを示します。
3.IsWhiteSpace(Char)
指定した Unicode 文字が空白かどうかを示します。
使用例
Imports System.Text
Module Module1
    Public Sub Main()
        '文字カウント変数
        Dim cnt As Integer = 0
        '空白カウント変数
        Dim nSpace As Integer = 0
        '符号カウント変数
        Dim cntMark As Integer = 0
        '可変型の文字列
        Dim sb As New StringBuilder("テス ト#データ123@.")
        'For文で可変型の文字列を表します
        For cft As Integer = 0 To sb.Length - 1
            Dim ch As Char = sb(cft)
            ' Unicode の文字かどうか
            If Char.IsLetter(ch) Then cnt += 1 : Continue For
            ' 空白かどうか
            If Char.IsWhiteSpace(ch) Then nSpace += 1 : Continue For
            '区切り記号かどうか
            If Char.IsPunctuation(ch) Then cntMark += 1
        Next
        Console.WriteLine("文字列 '{0}'の統計情報下記:", sb)
        Console.WriteLine("   アルファベット文字数: {0}", cnt)
        Console.WriteLine("   空白文字: {0}", nSpace)
        Console.WriteLine("   句読文字: {0}", cntMark)
        Console.ReadKey()
    End Sub
End Module
実行結果
文字列 'テス ト#データ123@.'の統計情報下記: アルファベット文字数: 6 空白文字: 1 句読文字: 3