Results 1 to 5 of 5

Thread: [02/03] Reading in a file into an array

  1. #1

    Thread Starter
    Fanatic Member Ggalla1779's Avatar
    Join Date
    Feb 2006
    Location
    Glasgow
    Posts
    532

    [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

  2. #2
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: [02/03] Reading in a file into an array

    what line gives error?
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  3. #3

    Thread Starter
    Fanatic Member Ggalla1779's Avatar
    Join Date
    Feb 2006
    Location
    Glasgow
    Posts
    532

    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)

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: [02/03] Reading in a file into an array

    where do you declare/dimension myFiles2?

  5. #5

    Thread Starter
    Fanatic Member Ggalla1779's Avatar
    Join Date
    Feb 2006
    Location
    Glasgow
    Posts
    532

    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width