try this:
step 1: save each favorite into an array
step 2: rewrite the text file line by line, comparing each line to the string representing the deleted favorite
step 3: if the favorite from the array is equal to the deleted favorite, skip to the next variable in the array.
step 4: when the loop is complete, your new favorites file will not have the deleted favorite
step 5: update the menu
here is the code:
VB Code:
public sub deletefavorite() ' build a variable containing all of the favorites open favoritefile for input as #1 do while not eof(1) line input #1, x fav = fav & "`" & x loop close 'convert the variable into an array array = split(fav, "`") 'clear the file of favorites open favoritefile for output as #1 print #1, "" close 'the loop rebuilding the file, excluding the deleted favorite for a = lbound(array) to ubound(array) if favorite_to_be_deleted = array(a) then goto 1 open favoritefile for append as #1 print #1, array(a) close 1 next a end sub




Reply With Quote