Find Most Repeated character in String

Sakthi.Singaravel
Posted by Sakthi.Singaravel under VB.NET category on | Points: 40 | Views : 1793
Imports System.IO
Module Module1
Sub Main()
Dim tempBig As Integer = 0
Dim tempChar As Char = vbNullChar
Dim str As String = "Hello"
Dim tempCount As Integer = 0
For Each ch As Char In str
tempCount = 0
For Each ch1 As Char In str
If ch = ch1 Then
tempCount += 1
End If
Next
If tempBig < tempCount Then
tempBig = tempCount
tempChar = ch
End If
Next
Console.WriteLine("Char : " + tempChar)
Console.WriteLine("Count : " + tempBig.ToString)
Console.Read()
End Sub
End Module

Comments or Responses

Login to post response