README.md

December 4, 2022 ยท View on GitHub

Auto Save/Load/Add/Remove - Lists

Description

Auto Save/Load/Add/Remove from/to a List

More Info

Submitted On
ByMatthew Gates
LevelBeginner
User Rating4.0 (8 globes from 2 users)
CompatibilityVB 3.0, VB 4.0 (16-bit), VB 4.0 (32-bit), VB 5.0, VB 6.0
CategoryFiles/ File Controls/ Input/ Output
WorldVisual Basic
Archive File

Source Code

Public Sub List_Add(List As ListBox, txt As String)
List.AddItem txt
End Sub
Public Sub List_Load(TheList As ListBox, FileName As String)
'Loads a file to a list box
On Error Resume Next
Dim TheContents As String
Dim fFile As Integer
fFile = FreeFile
 Open FileName For Input As fFile
  Do
   Line Input #fFile, TheContents$
    Call List_Add(TheList, TheContents$)
  Loop Until EOF(fFile)
 Close fFile
End Sub
Public Sub List_Save(TheList As ListBox, FileName As String)
'Save a listbox as FileName
On Error Resume Next
Dim Save As Long
Dim fFile As Integer
fFile = FreeFile
Open FileName For Output As fFile
  For Save = 0 To TheList.ListCount - 1
   Print #fFile, TheList.List(Save)
  Next Save
Close fFile
End Sub
Public Sub List_Remove(List As ListBox)
On Error Resume Next
If List.ListCount < 0 Then Exit Sub
 List.RemoveItem List.ListIndex
End Sub