Results 1 to 2 of 2

Thread: problem reading in records

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Oct 2003
    Posts
    149

    problem reading in records

    I am trying to read in a file and sort it with sort merge. I have this so far, but it gives me a object not set to instance of object error.
    Im new to vb and probably doing something dumb any help you could give me would be very helpful thanx


    Dim intfilenumber1, intfilenumber2 As Integer
    Dim array As ArrayList
    Dim index As Integer = 0
    Dim record1 As record


    TextBox1.Clear()
    TextBox1.Text = count

    'Open the file for read
    intfilenumber1 = FreeFile()
    FileOpen(intfilenumber1, "C:\file.txt", OpenMode.Input, OpenAccess.Read)
    Do While Not (EOF(intfilenumber1))
    'read in one record
    Input(intfilenumber1, record1.intaccountnum)
    Input(intfilenumber1, record1.strlastname)
    Input(intfilenumber1, record1.strfirstname)
    Input(intfilenumber1, record1.strmiddle)
    Input(intfilenumber1, record1.balance)
    Input(intfilenumber1, record1.dtdate)
    'put in array
    error here-> array.Add(record1)
    Loop
    FileClose(intfilenumber1)
    MergeSort(array, 0, array.Count - 1)
    'open for write
    intfilenumber2 = FreeFile()
    FileOpen(intfilenumber2, "C:\newfile.txt", OpenMode.Output)
    'write sorted file
    FileClose(intfilenumber2)
    End Sub

  2. #2
    Frenzied Member
    Join Date
    Oct 2002
    Location
    Gammapolis
    Posts
    1,474
    First: Why dont you use System.IO classes and members?
    Second: You shoud use
    VB Code:
    1. Dim array as New ArrayList
    'Heading for the automatic overload'
    Marillion, Brave, The Great Escape, 1994

    'How will WE stand the FIRE TOMORROW?'
    Eloy, Silent Cries and Mighty Echoes, The Vision - Burning, 1979

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