Would This Work! Simple Q for all.
Would this code work?
Not asking whether it's the best way just whether it would work or is it just my imagination!
This is to put whatever is in a list box into a text file also Remove items from a list box wherever they are(i.e middle of list or end etc.) and also remove them from the text file!
Read from text file to a list box:
Public Sub OPEN()
Dim FP As String
Dim Data1 As String
FP = "c:\my documents\vb\shortcuts\list_box.txt"
Open FP For Input As #1
Do Until EOF(1)
'Does this loop until End Of File(EOF) for file number 1.
Line Input #1, Data1
List1.AddItem Data1
Loop
Close #1
END SUB
Write whatever is in a list box to a text file:
Public Sub REFRESH()
FP = "c:\my documents\vb\shortcuts\list_box.txt"
Open FP For Output As #1
For x = 0 To List1.ListCount - 1
Print #1, List1.List(x)
Next x
Close #1
call open
end sub
Delete Any item in any order depending on which one is selected then update the text file!
Private Sub Command8_Click()
If List1.ListCount = 0 Or List1.ListIndex = -1 Then Exit Sub
tmpIndex = List1.ListIndex
List1.RemoveItem (List1.ListIndex)
If List1.ListCount = 0 Then Else If List1.ListIndex = 0 Then List1.ListIndex = tmpIndex Else List1.ListIndex = tmpIndex - 1
call REFRESH
End Sub