[02/03] Reading in a file into an array
"Latebound assignment to a field of value type 'myFiles' is not valid when 'myFiles' is the result of a latebound expression.
at Microsoft.VisualBasic.CompilerServices.LateBinding.LateSetComplex"
Am reading a file into an array, am getting a late binding error...can anyone see why its complaining???
cheers George
Code:
Public Sub FileCountLoad(ByRef myFiles2)
'OK Check if the file is there, if there Load it
'If not create file from standard master template
Dim FileReader As StreamReader
Dim LineIn As String
Dim FieldArray() As String
Dim Index As Integer
ChkMasterList(myFileList) 'Check todays file is there
Index = 0
Try
FileReader = File.OpenText(myFileList)
While FileReader.Peek <> -1
LineIn = FileReader.ReadLine()
FieldArray = Split(LineIn, ",")
myFiles2(Index).SPname = FieldArray(0)
myFiles2(Index).RRDname = FieldArray(1)
myFiles2(Index).Total = FieldArray(2)
myFiles2(Index).Freq = FieldArray(3)
Debug.WriteLine("Sp Name: " & myFiles2(Index).SPname & ", RRD Name:" & myFiles2(Index).RRDname & ", Category: " & myFiles2(Index).Total & ", Category: " & myFiles2(Index).Freq)
Index += 1
End While
FileReader.Close()
Catch ex As Exception
Debug.WriteLine("Friendly Error message, " & ex.ToString & "and" & ex.Message)
End Try
End Sub
Re: [02/03] Reading in a file into an array
Re: [02/03] Reading in a file into an array
Just here...when I try to add the value to the Array
Am using an array of a structure
myFiles2(Index).SPname = FieldArray(0)
Re: [02/03] Reading in a file into an array
where do you declare/dimension myFiles2?
Re: [02/03] Reading in a file into an array
ok I thought this was working yesterday...... I made a change so that I defined the array of structure outside the above routine...so I can call it in other routines ie output array to file
Dim myFiles2(300) As myFiles
that was line then passed the subroutine the array....for some reason it doesnt like it
Just put above routine in main module and it works fine...... can anyone explain why moving passing the array it doesnt like it?? Is this a structure bug?