Quote Originally Posted by John Wilson View Post
I was thinking that way too but I was surprised how fast the original code I posted runs.

John
Yea it's probably a wash for a few words. But ...

1. Run time is linear function of number of words being checked, 100 words = 100 times as long

2. It's on disc each time which is slower than memory, plus opening and closing takes time

3. Since the file is sorted, once you go past the word you're searching for you can exit the loop

4. Since the file is sorted, you could use a binary search and just narrow in on the word (possibly faster)

Maybe something like this untested tweak

Sub chex_Word() 
     
     ' word goes here
    If Not Word_exists("ABout") Then 
        MsgBox "It's not a word I know.", vbInformation 
    Else 
        MsgBox "It's a word I know.", vbInformation 
    End If 
End Sub 


Function Word_exists(strSearch As String) As Boolean 
    Dim strPath As String 
    strPath = Environ("USERPROFILE") & "\Desktop\dic.txt" 
    Dim strLine As String 
    Dim FileNum As Integer 

    Word_exists = False

    strSearch = LCase(strSearch) 

    FileNum = FreeFile 

    Open strPath For Input As #FileNum 

    Do While Not EOF(FileNum)  and strLine < strSearch
        Line Input #FileNum, strLine 
        If strLine = strSearch Then Word_exists = True 
    Loop 

    Close #FileNum 

End Function