Get alpha numeric count from a string Following is the code I am using to find a separate count for alphabets and numeric characters in a given alphanumeric string:

   Public Sub alphaNumeric(ByVal input As String)
        'alphaNumeric("asd23fdg4556g67gh678zxc3xxx")
        'input.Count(Char.IsLetterOrDigit)
        Dim alphaCount As Integer = 0 '&lt;-- initialize alphabet counter
        Dim numericCount As Integer = 0 '&lt;-- initialize numeric counter
        For Each c As Char In input '&lt;-- iterate through each character in the input
            If IsNumeric(c) = True Then numericCount += 1 '&lt;--- check whether c is numeric? if then increment nunericCounter
            If Char.IsLetter(c) = True Then alphaCount += 1 '&lt;--- check whether c is letter? if then increment alphaCount
        Next
        MsgBox("Number of alphabets : " &amp; alphaCount) '&lt;-- display the result
        MsgBox("Number of numerics : " &amp; numericCount)
    End Sub


Everything works fine for me. Let me know how I can make this simpler.
In general your code looks good, here are a few smaller remarks.

Method name:

Capitalize the name of your method and make it more meaningful. Use CountAlphaNumeric or something similar.

Comments in code:

You can omit the comments in your code. It speaks for itself what the code is doing, certainly because you use clear names for your variables.

IsNumeric() - Char.IsDigit():

In the .NET framework, there's the Char.IsDigit method, use this one instead:

If Char.IsDigit(c) = True Then numericCount += 1


MsgBox() - MessageBox.Show():

Although MsgBox is valid, it also comes from the VB era. In the .NET framework there's the MessageBox.Show method, use that one instead:

MessageBox.Show("Number of alphabets : " &amp; alphaCount)


String.Format():

To insert variables in a string, use the String.Format instead of just concatenating the values:

Dim result As String = String.Format("Number of alphabets : {0}", alphaCount)


"Expression = True":

You can leave out the = True part in your if conditions, since the methods return a boolean value.

This is what the code now looks like:

Public Sub CountAlphaNumeric(ByVal input As String)

    Dim alphaCount As Integer = 0
    Dim numericCount As Integer = 0

    For Each c As Char In input
        If Char.IsDigit(c) Then numericCount += 1
        If Char.IsLetter(c) Then alphaCount += 1
    Next

    MessageBox.Show(String.Format("Number of alphabets : {0}", alphaCount))
    MessageBox.Show(String.Format("Number of numerics : {0}", numericCount)

End Sub


Using LinQ:

Although not always the best option, you can achieve the same result using LinQ, using the Enumerable.Count method:

Dim alphaCount = input.Count(Function(c) Char.IsLetter(c))
Dim numericCount = input.Count(Function(c) Char.IsDigit(c))


Here's the complete code using LinQ:

Public Sub CountAlphaNumericUsingLinQ(ByVal input As String)

    Dim alphaCount = input.Count(Function(c) Char.IsLetter(c))
    Dim numericCount = input.Count(Function(c) Char.IsDigit(c))

    MessageBox.Show(String.Format("Number of alphabets : {0}", alphaCount))
    MessageBox.Show(String.Format("Number of numerics : {0}", numericCount))

End Sub