Click to See Complete Forum and Search --> : Deleting Files


RSH
August 3rd, 2001, 10:31 AM
With the following code generating a file how would one delete just the Individual array elements from the file and not delete the whole file. One can make each element = "" and save it but that still leaves the element with nothing in it. The above also leaves the (txt) Icon in place.

Private Sub Sorter()

For Y = 0 To 20
If SeqNo = Y Then Sources(Y) = Text1.Text: Combo1.List(Y) = Sources(Y): Typ(Y) = Text2.Text: Number(Y) = Text3.Text: Amount(Y) = Text4.Text: Rate(Y) = Text5.Text: DateIn(Y) = Text6.Text: DateOut(Y) = Text7.Text: SeqNum(Y) = Text8.Text
Next Y
Call FILER
End Sub

Private Sub FILER()
Close #1
Open "c:\Windows\Accounts.txt" For Output As #1

For Y = 0 To 20
Write #1, Sources(Y), Typ(Y), Number(Y), Amount(Y), Rate(Y), DateIn(Y), DateOut(Y), SeqNum(Y)
Next Y

Close #1
End Sub

CodeBlue
August 3rd, 2001, 10:30 PM
Anytime you open a file "for Output As...", you're really deleting the entire contents of the file. So, if you issue the commands

Open "c:\Windows\Accounts.txt" for Output as #1
Close #1



you'll have a zero-byte (empty) file. The (txt) icon will be visible until you completely delete the file.