Results 1 to 2 of 2

Thread: Remove Blank Records From Random Access File

  1. #1

    Thread Starter
    Addicted Member señorbadger's Avatar
    Join Date
    Oct 2003
    Location
    Mud pools of wellingborough
    Posts
    193

    Remove Blank Records From Random Access File

    Hi everyone

    i have written a simple random access file application but was
    wondering how to delete a empty record i am using a UDT like
    below

    VB Code:
    1. Public Type record
    2.         staff_name      As String * 20
    3.         title                  As String * 4
    4.         initials              As String * 4
    5.         status              As String * 1
    6.         room                As String * 5
    7.         telephone        As String * 4
    8.     End Type

    any ideas how to delete a blank record

    thanks for help people

  2. #2
    Lively Member
    Join Date
    Mar 2004
    Location
    UK
    Posts
    109
    Try this:-

    Private Sub CleanUpFile()
    Dim CleanFileNum As Integer
    Dim i As Long
    Dim Confirm As Integer

    ' removes any duplicates by copying to another file
    Confirm = False
    CleanFileNum = FileOpener("~~Tmp~~.Tmp", RANDOMFILE, Len(Contact), Confirm)
    For i = 1 To LastRecord
    Get #FileNum, i, Contact
    Put #CleanFileNum, i, Contact
    Next i
    Close
    ' rename file
    FileCopy "~~Tmp~~.Tmp", FileName
    FileNum = FileOpener(FileName, RANDOMFILE, Len(Contact), Confirm)
    Kill "~~Tmp~~.Tmp"
    End Sub

    I found it in the samples for VB3 called fileio\recedit.mak bt I'm not sure if it works for blanks.

    Nick
    UK Software Development http://www.all4yourpc.co.uk

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