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.txt" 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.txt" 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