Imports System
Public Class Program
Public Shared Sub countDigits(ByVal s As String)
Dim size As Integer = s.Length
If size = 0 Then
Console.Write("String is empry")
Return
End If
Dim digit_frequency As Integer() = New Integer() {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}
For i As Integer = 0 To size - 1
If Char.IsDigit(s(i)) Then
digit_frequency(Convert.ToByte(s(i)) - Convert.ToByte("0"c)) += 1
End If
Next
For j As Integer = 0 To 10 - 1
Console.WriteLine(j & ": " & digit_frequency(j) & " times")
Next
End Sub
Public Shared Sub Main(ByVal args As String())
Dim s As String = "vb.net23c++4523java23988rust82215"
countDigits(s)
End Sub
End Class
' run:
'
' 0: 0 times
' 1: 1 times
' 2: 5 times
' 3: 3 times
' 4: 1 times
' 5: 2 times
' 6: 0 times
' 7: 0 times
' 8: 3 times
' 9: 1 times
'