Deleting Info From Write File

deathman5
09-29-2004, 10:38 AM
Im working on an IRC program, Im trying now to save the servers, so the user wont have to remember them all
I have a list box, I put inside it the server names that are saved using this code
Text1 = Server
Text2 = Port

Dim Ser(2500) As String
Dim Por(2500) As String
Dim TotalWords As Integer

Private Sub Command6_Click()
'How To Save
Ser(TotalWords) = Text1.Text
Por(TotalWords) = Text2.Text
Open "Servers.dat" For Append As #1
Write #1, Ser(TotalWords), Por(TotalWords)
Close
TotalWords = TotalWords + 1

'How To Load
List1.Clear
TotalWords = 0
Open "Servers.dat" For Input As #1
Do Until EOF(1) = True
Input #1, Ser(TotalWords), Por(TotalWords)
TotalWords = TotalWords + 1
Loop
Close
Dim x As Integer
For x = 0 To TotalWords - 1
List1.AddItem Ser(x)
DoEvents
Next x
End Sub


Ok the problem is, I want to make the user able to remove some servers by highlighting them on the list and clicking command button, but then I have to remove them from the file it self and I must not keep any blank lines or spaces in the file (need that for another thing)
So how to do that?

Ziess
09-29-2004, 12:00 PM
well you could just rewrite the file over again with the new data... or...

you could go though the file line by line and jsut look for the data, then copy all teh data that is not that line into a variable, then print the variable. not mater what you are rewriting the file. unless you want to open it for binary, and go though it char by char, and change them by selecting wher eyou are in the file... way easyer to jsut rewrite the file, lol

-Ziess

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum