求VB统计数字出现频率的代码
求VB统计数字出现频率的代码:有多个text(如16个),16个text里面有某个数字,统计每个数字出现的次数,并在list1里次数从多到少显示出来如:1多少次2多少次,...
求VB统计数字出现频率的代码:有多个text(如16个),16个text里面有某个数字,统计每个数字出现的次数,并在list1里次数从多到少显示出来如:1多少次 2多少次,vb代码急
展开
展开全部
由于学了很久了,只能写到下面这个地步,下面的代码可以运行得到你要的结果
Private Sub Command1_Click()
Dim strTest As String
Dim bytArray() As Byte
Dim intcount As Integer
strTest = Text1.Text
bytArray = strTest
For intcount = 0 To UBound(bytArray)
If (bytArray(intcount) = Asc("0")) Then zo = zo + 1
If (bytArray(intcount) = Asc("1")) Then one = one + 1
If (bytArray(intcount) = Asc("2")) Then two = two + 1
If (bytArray(intcount) = Asc("3")) Then three = three + 1
If (bytArray(intcount) = Asc("4")) Then four = four + 1
If (bytArray(intcount) = Asc("5")) Then five = five + 1
If (bytArray(intcount) = Asc("6")) Then six = six + 1
If (bytArray(intcount) = Asc("7")) Then sev = sev + 1
If (bytArray(intcount) = Asc("8")) Then eight = eight + 1
If (bytArray(intcount) = Asc("9")) Then nine = nine + 1
Next
List1.AddItem "0: " & zo
List1.AddItem "1: " & one
List1.AddItem "2: " & two
List1.AddItem "3: " & three
List1.AddItem "4: " & four
List1.AddItem "5: " & five
List1.AddItem "6: " & six
List1.AddItem "7: " & sev
List1.AddItem "8: " & eight
List1.AddItem "9: " & nine
End Sub
Private Sub Command1_Click()
Dim strTest As String
Dim bytArray() As Byte
Dim intcount As Integer
strTest = Text1.Text
bytArray = strTest
For intcount = 0 To UBound(bytArray)
If (bytArray(intcount) = Asc("0")) Then zo = zo + 1
If (bytArray(intcount) = Asc("1")) Then one = one + 1
If (bytArray(intcount) = Asc("2")) Then two = two + 1
If (bytArray(intcount) = Asc("3")) Then three = three + 1
If (bytArray(intcount) = Asc("4")) Then four = four + 1
If (bytArray(intcount) = Asc("5")) Then five = five + 1
If (bytArray(intcount) = Asc("6")) Then six = six + 1
If (bytArray(intcount) = Asc("7")) Then sev = sev + 1
If (bytArray(intcount) = Asc("8")) Then eight = eight + 1
If (bytArray(intcount) = Asc("9")) Then nine = nine + 1
Next
List1.AddItem "0: " & zo
List1.AddItem "1: " & one
List1.AddItem "2: " & two
List1.AddItem "3: " & three
List1.AddItem "4: " & four
List1.AddItem "5: " & five
List1.AddItem "6: " & six
List1.AddItem "7: " & sev
List1.AddItem "8: " & eight
List1.AddItem "9: " & nine
End Sub
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询