1

I've been coding a Film Search thing for School, and I've came across this problem and I'm not sure how to solve it.

While Not FilmSearcher.EndOfData         'loop until end of file
    currentRow = FilmSearcher.ReadFields()   'read in the fields of each line
    For j = 0 To 3
        Films(i, j) = currentRow(j)      'put the fields into film array
    Next

    i = i + 1
End While

currentRow = FilmSearcher.ReadFields() is the part that isn't working

1
  • 1
    Show the filmsearch.readfields code. Commented Oct 4, 2013 at 20:14

3 Answers 3

6

If the error message is in your title, then I bet you have declared the currentRow as

Dim currentRow As String

instead you need to declare it as a 1-dimensional array

Dim currentRow() as String
Sign up to request clarification or add additional context in comments.

Comments

0

Your currentRow variable is not declared correctly. Instead of this:

Dim currentRow As String

You need one of these:

Dim currentRow() As String
Dim currentRow As String()

Which one you choose is a matter of preference. They mean the same thing. You can also avoid the variable entirely:

While Not FilmSearcher.EndOfData        
    'read in the fields of each line and put into film array
    Films(i) = FilmSearcher.ReadFields()          
    i = i + 1
End While

Comments

0

In my case, I had declared my method incorrectly to return an array:

Function GetById(ByVal id As Integer) As String

and the syntax should be:

Function GetById(ByVal id As Integer) As String()

whereas I can return an array of strings:

Dim arrayOfStrings() As String
arrayOfStrings = {"John", "Josh", "Jason", "Jill", "Kunta Kinte"}
Return arrayOfStrings

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.