VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Save And Load a listview in report view from a sequantial file

by Looi Tuck Wai (5 Submissions)
Category: OLE/COM/DCOM/Active-X
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Thu 8th July 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Save And Load a listview in report view from a sequantial file

Rate Save And Load a listview in report view from a sequantial file



Author   : Looi Tuck Wai
Control  : 3 Command Button(cmdAdd,cmdSave,cmdLoad),2 Textbox(Text1,Text2),   
           1 listview(lv)

Code     :
Dim a(100) As String
Dim b(100) As String
Dim i As Integer

Private Sub CmdAdd_Click()
Dim itm As ListItem
      Set itm = lv.ListItems.Add(, , Text1.Text)
      itm.SubItems(1) = Text2.Text
End Sub

Private Sub CmdSave_Click()
    For i = 1 To Form1.lv.ListItems.Count
        a(i) = Form1.lv.ListItems(i).Text
        b(i) = Form1.lv.ListItems(i).SubItems(1)
        Next i
        ItemCount = Form1.lv.ListItems.Count
    Open "c:\test.lis" For Output As #1
    For i = 1 To ItemCount
        Write #1, a(i), b(i)
        Next i
        Close #1       
End Sub

Private Sub CmdLoad_Click()
Dim itm As ListItem
Dim a, b As String
    Open "c:\test.lis" For Input As #1
    Do Until EOF(1)
    Input #1, a, b
              Set itm = lv.ListItems.Add(, , a)
              itm.SubItems(1) = b
    Loop
    Close #1
End Sub

Private Sub Form_Load()
lv.View = lvwReport
lv.ColumnHeaders.Add , , "Name"
lv.ColumnHeaders.Add , , "Age"
End Sub

Download this snippet    Add to My Saved Code

Save And Load a listview in report view from a sequantial file Comments

No comments have been posted about Save And Load a listview in report view from a sequantial file. Why not be the first to post a comment about Save And Load a listview in report view from a sequantial file.

Post your comment

Subject:
Message:
0/1000 characters