判断一串字符中相同字符的最大个数?

来源:百度知道 编辑:UC知道 时间:2024/05/09 05:52:27
示:132112中有个3个1,2个2,则返回3
求vb函数?

根据你的要求写了一个程序。
运行无误。
希望对你有所帮助
在窗体中添加一个textbox,一个commadnbutton

Private Sub Command1_Click()
Dim str1 As String, str2 As String, intN As Integer, intMax As Integer
str1 = Text1.Text
intN = Len(str1)
Do
str2 = Left(str1, 1)
str1 = Replace(str1, str2, "")
intMax = IIf(intMax > intN - Len(str1), intMax, intN - Len(str1))
intN = Len(str1)
Loop Until intN = 0
MsgBox intMax
End Sub

这个都是自己编程实现的.