
Originally Posted by
DroopyPawn
If I add a "ListOfWords.txt" as a compiled resource and then get the "list of words" into a string, I could split the string into an array using vbCrLf as the delimiter, right?
Heres one way to load a text file into a string array.
Code:
Option Explicit
Private Sub Command1_Click()
Dim i As Long
Dim MyArray() As String
FileToArray "SomeFile.txt", MyArray
For i = 0 To UBound(MyArray)
' ignore blank lines
If Len(MyArray(i)) > 0 Then Debug.Print MyArray(i)
Next i
End Sub
Private Sub FileToArray(ByVal sPath As String, ByRef sArray() As String)
Dim ff As Integer
ff = FreeFile
On Error GoTo Fini
Open sPath For Input As #ff
sArray = Split(Input(LOF(ff), ff), vbCrLf)
Fini:
Close #ff
End Sub