标题:【求助】 关于Text2每行排序问题,敬请大侠们帮助!
只看楼主
回头一看
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2018-7-18
得分:0 
得到众版主的支持,非常感谢,谢谢!!!
2018-08-04 19:28
回头一看
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2018-7-18
得分:0 
回复 10楼 xzlxzlxzl
请教大师      n(k) = n(k) & m(i) & ","    这里下标越界问题
Private Sub Command1_Click()
Dim i As Integer, j As Integer, k As Integer, m() As String, n() As String, s As String, t As String
    s = "赵,钱,孙,陈"        '统计过程中,受限于这个值,如这里是4个姓,统计重复“孙,孙,孙,”就出错,
                             ‘假如 s = "赵,钱,孙,陈,黄"  这里是5个姓,统计重复“孙,孙,孙,”没问题,
    t = Text1.Text & ","
    m = Split(s, ",")
    ReDim n(UBound(m))
    For i = 0 To UBound(m)
      j = 1
      k = 0
      While InStr(j, t, m(i) & ",")
        k = k + 1
        j = InStr(j, t, m(i) & ",") + 1
      Wend
      n(k) = n(k) & m(i) & ","
    Next
    Text2 = ""
    For i = 0 To UBound(n)
      If n(i) <> "" Then
        Text2 = Text2 & "【共" & i & "人次】:" & n(i) & "(" & Len(n(i)) / 2 & "个姓)" & vbCrLf
      End If
    Next
End Sub

Private Sub Form_Load()
Text1.Text = "孙,孙,孙,孙"
End Sub
2018-08-06 20:50
xzlxzlxzl
Rank: 15Rank: 15Rank: 15Rank: 15Rank: 15
来 自:湖北
等 级:贵宾
威 望:125
帖 子:1091
专家分:5825
注 册:2014-5-3
得分:0 
回复 12楼 回头一看
一个低级Bug,把语句“ReDim n(UBound(m))”修改为“ReDim n(len(t)/2)”即可。
2018-08-07 19:06
回头一看
Rank: 1
等 级:新手上路
帖 子:11
专家分:0
注 册:2018-7-18
得分:0 
回复 13楼 xzlxzlxzl
谢谢大师!!!
2018-08-07 21:07



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-488995-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.085007 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved