Dim str As String = "aaabfffcccccjjjjjjjhhyz" Dim mc = System.Text.RegularExpressions.Regex.Matches(str, "(.)\1+") Dim max As Integer = 0 Dim ns As String = "" For i As Integer = 0 To mc.count-1 Dim s As String = mc(i).value If s.length > max Then max = s.length ns = s End If Next msgbox(ns)