Load text from File to array??

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Evil Homer
    New Member
    • Nov 2006
    • 5

    Load text from File to array??

    I have been trying to make a function in vb6 for first, loading some words from a file (one word on each line in the file, a dictionary) and then putting them into a array...

    But im having a hard time getting it to work, can somone help me? Pretty please? :P
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    Originally posted by Evil Homer
    I have been trying to make a function in vb6 for first, loading some words from a file (one word on each line in the file, a dictionary) and then putting them into a array...

    But im having a hard time getting it to work, can somone help me? Pretty please? :P
    Ok, here's a quick one just off the top of my head...
    Code:
    Option Explicit
    Public Word() As String
    Public WordCount as long
    Public Sub LoadWords()
    dim FileNum as Long
    FileNum=FreeFile
    Open "Words.txt" for input access read shared as #FileNum
    do until eof(FileNum)
      WordCount = WordCount + 1
      Redim Preserve Word(1 To WordCount)
      Line Input #FileNum, TempWord(WordCount)
    Loop
    Close #FileNum
    End Sub

    Comment

    Working...