VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



This code will will allow to save the data of a list in a file and open that file for furthur use.T

by vipin jain (2 Submissions)
Category: Custom Controls/Forms/Menus
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Fri 25th February 2000
Date Added: Mon 8th February 2021
Rating: (1 Votes)

This code will will allow to save the data of a list in a file and open that file for furthur use.This helps in adding data in the list every

Rate This code will will allow to save the data of a list in a file and open that file for furthur use.T



Dim i As String
i = InputBox("enter string")
List1.AddItem i
End Sub

Private Sub Command2_Click()    'open existing list
OpenList List1
End Sub

Private Sub Command3_Click()    'save current list items in a file
  SaveList List1
End Sub

Private Sub SaveList(lst As ListBox)
Dim a As Integer
Dim ff As Integer
Dim Header As String
Dim LCount As Long
Dim numbyte As Byte
ff = FreeFile
Open "C:\list.lst" For Binary As #1
Header = "SavedList"
Put ff, 1, Header
LCount = lst.ListCount
Put ff, , LCount
For a = 0 To lst.ListCount - 1
    numbyte = Len(lst.List(a))
    Put ff, , numbyte
    Put ff, , lst.List(a)
Next a
Close ff
End Sub

Private Sub OpenList(lst As ListBox)
Dim a As Integer
Dim ff As Integer
Dim LCount As Long
Dim data As String
Dim numbyte As Byte

ff = FreeFile

Open "C:\list.lst" For Binary As #1
    data = "SavedList"
    Get ff, 1, data
    Get ff, , LCount
    If data = "SavedList" Then
        For a = 0 To LCount - 1
            Get ff, , numbyte
            data = String(numbyte, " ")
            Get ff, , data
            lst.AddItem (data)
        Next a
    Else
        MsgBox "Error loading list: Bad file"
    End If
Close ff
End Sub

Download this snippet    Add to My Saved Code

This code will will allow to save the data of a list in a file and open that file for furthur use.T Comments

No comments have been posted about This code will will allow to save the data of a list in a file and open that file for furthur use.T. Why not be the first to post a comment about This code will will allow to save the data of a list in a file and open that file for furthur use.T.

Post your comment

Subject:
Message:
0/1000 characters