1
我正在學習編程,並與我在VBA中編寫的程序有問題,但我無法弄清楚我出錯的地方。對不起,如果這比你通常處理的基礎太過基礎,但是VBA比Python更難學,而且我有很多問題,所以如果你能指出這個錯誤,我會很感激。對不起,如果這是在錯誤的地區。VBA程序來搜索字典文本文件,看看有沒有一個字是不正確的
它有時會給出誤報,例如當「計算機」輸入時返回「conspirantFound!」,但我無法弄清楚原因。
Option Explicit
Sub Ne()
Dim PathString As String
Dim Filenum As Integer
Dim i As Integer
Dim word As String
Dim searchword As String
Dim Wordfound As Boolean
searchword = InputBox("Input your word")
LCase (searchword)
PathString = Application.ActiveWorkbook.Path
Filenum = FreeFile()
Open PathString + "\dictionary.txt" For Input As Filenum
Wordfound = False
For i = 1 To 10000
Input #Filenum, word
If word = searchword Then
Wordfound = True
Else
Next i
End If
If Wordfound = True Then MsgBox word + "Found" Else MsgBox ("Word not Found")
Close Filenum
End Sub