VB 6.0 RunTime Error 13 Type Mismatch?

i’m Trying to work with ListView
Here is my whole Script :

Option Explicit
Sub AddColumnHeader(Lvw As ListView, ParamArray col())
Dim i9 As Integer
For i = 0 To UBound(col)
Lvw.ColumnHeaders.Add , , col(i)
Next
Lvw.View = lvwReport
Lvw.GridLines = True
Lvw.FullRowSelect = True
End Sub

Public Sub AddDataToLvw(Lvw As ListView, ParamArray Data())
Dim i As Integer
Dim Litem As ListItem
Set letem = Lvw.ListItems.Add(, , Data(0))
For i = 1 To UBound(Data)
Litem.SubItems(i) = Data(i)
Next
End Sub
Private Sub CMDRead_Click()
Dim ID, Name, Sex, DOB, Adr As String
ListViews1.ListItems.Clear
Open "D:/Room311/StudentInfo.txt" For Input As #1
While Not EOF(1)
Input #1, ID, Name, Sex, DOB, Adr
Call AddDataToLvw(ListView1, ID, Name, Sex, DOB, Adr)
Wend
Close #1
End Sub

Private Sub CMDWrite_Click()
Open "D:/Room311/StudentInfo.txt" For Append As #1

Write #1, TXTID, TXTName, TXTSex, TXTDob, TXTAdr
Close #1
TXTID = ""
TXTName = ""
TXTSex = ""
TXTDob = ""
TXTAdr = ""

End Sub

Private Sub Form_Load()
Call AddColumnHeader(Me.ListView1, "ID", "Name", "Sex", "DOB", "Address")
End Sub

If you use Ctrl+F5 to run your program, you will see some of the errors

Some spelling mistakes:
Dim i9 As Integer

Set letem = Lvw.ListItems.Add(, , Data(0))

ListViews1.ListItems.Clear

Leave a Reply