一个统计的问题,
是在有难度,不会,请帮忙看看.效果如图:
http://hiphotos.baidu.com/%CC%EC%B7%E7%BA%A3%CB%AE/pic/item/a5e42f6d39d677fc43169424.jpg
一个车间统计,总共12个小组,统计每期次数.
01组,02组,03组,04组,05组,06组,07组,08组,09组,10组,11组,12组,
文本框1内容:
第1期
01组,03组,08组,03组,
12组,03组,05组,02组,
10组,03组,04组,09组,
第2期
03组,03组,05组,06组,
06组,11组,10组,02组,
08组,06组,01组,10组,
第3期
.....
统计结果:(输出到文本框2)
第1期
(0次) 06组,07组,11组, [共3个]
(1次) 01组,02组,04组,05组,08组,09组,12组,10组,[共8个]
(4次) 03组, [共1个]
第2期
(0次) 04组,07组,09组,12组[共4个]
(1次) 01组,02组,05组,08组,11组,[共5个]
(2次) 10组,03组[共2个]
(3次) 06组, [共1个]
第3期
.....
[解决办法]
数据不全,根本无法理解你的意思
[解决办法]
帮你测试的代码,你参考一下
Option Explicit
Private Sub Command1_Click()
Dim s As String
Dim str() As String
Dim i As Integer, j As Integer, k As Integer
Dim arrGrp As Variant
Dim strNum(0 To 12) As String
Dim n As Integer
s = Replace(Text1, vbCrLf, vbNullString)
s = Replace(s, "第1期 ", "@@ ")
s = Replace(s, "第2期 ", "@@ ")
s = Replace(s, "第3期 ", "@@ ")
s = Replace(s, "第4期 ", "@@ ")
'......
str = Split(s, "@@ ")
arrGrp = Array( "01组 ", "02组 ", "03组 ", "04组 ", "05组 ", "06组 " _
, "07组 ", "08组 ", "09组 ", "10组 ", "11组 ", "12组 ")
For i = 1 To UBound(str)
For j = 0 To UBound(arrGrp)
strNum(UBound(Split(str(i), arrGrp(j)))) = _
strNum(UBound(Split(str(i), arrGrp(j)))) & arrGrp(j) & ", "
Next
Text2 = Text2 & "第 " & i & "期 " & vbCrLf _
& vbCrLf
For k = 0 To 12
If Trim(strNum(k)) <> " " Then
n = UBound(Split(strNum(k), ", "))
Text2 = Text2 & "( " & k & " 次): " & strNum(k) _
& "[共 " & n & "个] " & vbCrLf
End If
Next
Text2 = Text2 & vbCrLf
Erase strNum
Next
End Sub
Private Sub Form_Load()
Text1 = "第1期 " & vbCrLf _
& vbCrLf _
& "01组,03组,08组,03组, " & vbCrLf _
& "12组,03组,05组,02组, " & vbCrLf _
& "10组,03组,04组,09组, " & vbCrLf _
& vbCrLf _
& "第2期 " & vbCrLf _
& vbCrLf _
& "03组,03组,05组,06组, " & vbCrLf _
& "06组,11组,10组,02组, " & vbCrLf _
& "08组,06组,01组,10组, "
Text2 = vbNullString
End Sub