How can I check special characters are there (String) or Display on label?
I Use this but it is only count

Dim input As String = "Hi! Hello, How are you?"
        Dim pattern As String = "[!""#$%&'()*+,\-./:;<=>?@[\\\]^_`{|}~\s]"
        Dim matches As MatchCollection = Regex.Matches(input, pattern)
        MessageBox.Show(String.Format("There are {0} special characters in the input '{1}'", matches.Count, input))

how to display what special Chr are there in this string

Public Class Form1
    Dim myarr() As Char 'create an array to hold the specil characters'
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        TextBox1.Text = "Hi! Hello, How are you?"
        myarr = {"[", "!", "#", "$", "%", "&", "'", "(", ")", "*", "+", ",", "\", "-", ".", "/", ":", ";", "<", "=", ">", "?", "@", "]", "^", "_", "{", "|", "}", "~", "§"}
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Application.Exit()
    End Sub

    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
        Dim n As Integer = Len(myarr)
        Dim i As Integer
        For i = 0 To n - 1
            If TextBox1.Text.Contains(myarr(i)) Then
                Debug.Print(myarr(i))' print character if found
            End If
        Next
    End Sub
End Class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.