用vb统计一个txt文件的某一字母的个数

来源:百度知道 编辑:UC知道 时间:2024/06/22 20:14:30
用到那些控件?
怎么写?
怎么实现?

怎么实现可以文本文件用户可以选择呢
怎么统计文件中的行数呢

一个command控件,一个text控件
C:\1.text可以换成自己需要的路径及文件名称
Private Sub Command1_Click()
Dim a As Long
Dim yjg As String
a = 0
Open "c:\1.txt" For Input As #1
Do Until EOF(1)
Line Input #1, yjg
For i = 1 To Len(yjg)
If Mid$(yjg, i, 1) = Text1.Text Then
a = a + 1
End If
Next i
Loop
Close #1
MsgBox "字母" & Text1.Text & "的个数是:" & a
End Sub

http://hi.baidu.com/%B7%BF%B6%F7%BA%EA/blog/item/56917ac2ec2c4e120ef47726.html