Results 1 to 2 of 2

Thread: deleting records

  1. #1
    Guest
    here is my code:

    FileNumber = FreeFile()
    Open "C:\TestFile.txt" For Random As FileNumber Len = Len(rec)
    Do Until EOF(FileNumber)
    i = i + 1
    Get FileNumber, i, rec
    Loop

    'rec is the UDT;
    'variable i will return the number of records
    'that are in the file

    the problem i have is when i delete a record
    the length of the UDT still remains in the file
    which therefore, in my case, variable i will return an
    incorrect number.

    if anyone knows a way to remove the dead space from
    a deleted record in a random access file let me know





  2. #2
    Member
    Join Date
    Aug 2000
    Posts
    60

    Cool

    You can remove spaces by loading all the data into an array (if you don't know about arrays there is a good tutorial on http://www.vb-world.net at the moment) then loop through all of the items in the array ( The highest item number can be found by using the UBound command e.g:
    LastItem = UBound(Array())

    Where LastItem is the highest item number and Array() is your array containing the data you have loaded. Before writing them to the file you can check the value of the item, if it is equal to nothing ("") then skip the write function on that occasion.

    Hope this helps if you need further help or examples please feel free to contact me on

    icq: 33122184
    or by e-mail: [email protected]

    Grant

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