這些是我已完成程式ㄉ部分!!
功能是:可以輸入一篇文章..然後可自行輸入關鍵字去查詢..此關鍵字在文章內出現過幾次!!
但現在我想要把他改成...他自己可以去抓取文章...而不是我自己複製貼上!
help me~~~~~~~~~~~~~~~~
Private Sub Command1_Click()
Dim vKeyWord
Dim vWord
Dim vKeyWordLen
Dim t
t = 0
vWord = Text1
vKeyWord = txtKeyWord
vKeyWordLen = Len(vKeyWord)
If vKeyWordLen > 0 Then
Do While (InStr(1, vWord, vKeyWord) > 0)
t = t + 1
vWord = Mid(vWord, InStr(1, vWord, vKeyWord) + vKeyWordLen)
Loop
End If
MsgBox "共出現" & t & "次"
End Sub
2006-11-06 10:24:55 · 1 個解答 · 發問者 ru3 2 in 電腦與網際網路 ➔ 軟體
不好意思再請問..可否讓他先把檔案叫出來後...在去輸入關鍵字查詢呢?對了~WJS有即時通或MSN嗎?還有事想請叫你..謝謝
2006-11-07 15:32:36 · update #1
我已經研究出來ㄌ!!謝謝!!不過還是想請問你有無MSN或及時通!!還是有其他ㄉ想要請問你!!謝謝
2006-11-07 17:31:37 · update #2
'Text1的MultiLine設為True,ScrollBars設為3-兩者皆有Private Sub Command1_Click() Dim vKeyWord As String, vWord As String, vKeyWordLen As Long, t As Long Dim nPath As String, f As Long, S As String '輸入檔案路徑 nPath = InputBox("請輸入檔案路徑", "", "C:\Test.txt") If nPath = "" Then Exit Sub If Dir(nPath) = "" Then MsgBox "檔案路徑錯誤!" Exit Sub End If '讀檔 f = FreeFile Open nPath For Input As #f Do Until EOF(f) Line Input #1, S vWord = vWord & S & vbCrLf Loop Close #f vWord = Left(vWord, Len(vWord) - 1) '放入Text1 Text1 = vWord vKeyWord = txtKeyWord '可用此種方法 MsgBox "共出現" & UBound(Split(vWord, vKeyWord)) & "次" '你的方法 vKeyWordLen = Len(vKeyWord) If vKeyWordLen > 0 Then Do While (InStr(1, vWord, vKeyWord) > 0) t = t + 1 vWord = Mid(vWord, InStr(1, vWord, vKeyWord) + vKeyWordLen) Loop End If MsgBox "共出現" & t & "次"End Sub
2006-11-08 13:54:47 補充:
如果有問題,您可寄信給我,大家一起研究.
2006-11-07 13:08:10 · answer #1 · answered by W.J.S. 7 · 0⤊ 0⤋