1111.txt中有如下内容
04.16.17.18.26.29
03.08.09.10.11.14
05.07.09.14.19.26
04.06.09.11.15.19
04.08.16.18.31.32
06.08.16.19.27.31
05.19.22.27.28.29
01.05.10.11.22.28
03.11.17.25.30.31
02.04.07.15.18.24
06.11.17.20.27.33
02.05.15.18.20.30
04.08.15.17.20.29
05.07.15.18.20.27
我想查找其中01 02 03 04 05 06 07 08 09 10出现的个数显示出来查找结果应如下
01=1
02=1
03=2
04=3
05=2
06=0
...
如何编程 谢了
04.16.17.18.26.29
03.08.09.10.11.14
05.07.09.14.19.26
04.06.09.11.15.19
04.08.16.18.31.32
06.08.16.19.27.31
05.19.22.27.28.29
01.05.10.11.22.28
03.11.17.25.30.31
02.04.07.15.18.24
06.11.17.20.27.33
02.05.15.18.20.30
04.08.15.17.20.29
05.07.15.18.20.27
我想查找其中01 02 03 04 05 06 07 08 09 10出现的个数显示出来查找结果应如下
01=1
02=1
03=2
04=3
05=2
06=0
...
如何编程 谢了
Private Sub Command1_Click()
'窗体里加一个ListBox用来显示结果
Dim TextLine As String
Dim a(10) As String
Dim b(10) As Integer
For i = LBound(a) To UBound(a)
a(i) = Format(i + 1, "00")
Next i
Open App.Path & "\111.txt" For Input As #1
Do While Not EOF(1) ' 循环至文件尾。
Line Input #1, TextLine ' 读入一行数据并将其赋予某变量。
For i = LBound(b) To UBound(b)
If InStr(1, TextLine, a(i)) <> 0 Then
b(i) = b(i) + 1
End If
Next i
Loop
Close #1
For i = LBound(a) To UBound(a)
List1.AddItem b(i)
Next i
End Sub
Private Sub Command1_Click()
'窗体里加2个ListBox用来显示结果
Dim TextLine As String
Dim a(9) As String
Dim b(9) As Integer
For i = LBound(a) To UBound(a)
a(i) = Format(i + 1, "00")
Next i
Open App.Path & "\111.txt" For Input As #1
Do While Not EOF(1) ' 循环至文件尾。
Line Input #1, TextLine ' 读入一行数据并将其赋予某变量。
For i = LBound(b) To UBound(b)
If InStr(1, TextLine, a(i)) <> 0 Then
b(i) = b(i) + 1
End If
Next i
Loop
Close #1
For i = LBound(a) To UBound(a)
List1.AddItem a(i)
List2.AddItem b(i)
Next i
End Sub
Option Base 1
Private Sub Form_Click()
Dim arr() As String
Dim brr(10) As Integer
Dim Sum As Integer
Open App.Path & "\" & "1111.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, x$
Sum = Sum + 1
arr = Split(x$, ".")
For i = 0 To UBound(arr)
mystr = Str(Val(arr(i)))
For j = 1 To 10
If mystr = Str(j) Then
Sum = brr(j)
Sum = Sum + 1
brr(j) = Sum
End If
Next
Next
Loop
For i = 1 To 10
Debug.Print Format(i, "00") & "=" & brr(i)
Next
Close
End Sub
Private Sub Form_Click()
Dim arr() As String
Dim brr(10) As Integer
Dim Sum As Integer
Open App.Path & "\" & "1111.txt" For Input As #1
Do While Not EOF(1)
Line Input #1, x$
Sum = Sum + 1
arr = Split(x$, ".")
For i = 0 To UBound(arr)
mystr = Str(Val(arr(i)))
For j = 1 To 10
If mystr = Str(j) Then brr(j) = brr(j) + 1
Next
Next
Loop
For i = 1 To 10
Debug.Print Format(i, "00") & "=" & brr(i)
Next
Close
End Sub
Dim Counter(9) As Integer, i As Long, n As IntegerOpen App.Path & "\" & "1111.txt" For Binary As #1
Redim bytData(LOF(1) - 1)
Get #1, , bytData
Close #1strFile = StrConv(bytData, vbUnicode)strFile = Replace(strFile, vbNewLine, vbTab)
strItem = Split(strFile, vbTab)For i = 0 To Ubound(strItem)
n = Val(strItem(i) - 1)
If n < 10 Then Counter(n) = Counter(n) + 1
Next iFor i = 0 To 9
Debug.Print Right("0" & (i + 1), 2) & ": " & Counter(i)
Next i
strItem = Split(strFile, ".")