Am upgrading an application from VB6 to VB.Net. One of the controls is a ListView that am failing to populate. Am including some of the code for some assistance where I may be going wrong.
Private Sub ShowFielgs()
Dim f As ListViewItem
Dim i As Integer
Dim Names as String
Dim Arr6() As Object
With tbStaffm
Dim date1 As Date = Now
Dim date2 As Date = .Fields("BirthDate").Value
Dim DateDifference As Integer = (DateDiff(DateInterval.DayOfYear, date2, date1) \ 30 \ 12)
Names = ""
i = 0
If .RecordCount > 0 Then
ListView.Items.Clear()
.MoveFirst()
Do While Not .EOF
If StrComp(Trim(.Fields(StaffCode).Value), Trim(cboStaffCode.Text))=0 Then
f = ListView.Items(i)
ReDim Arr6(i)
Arr6(i) = .Bookmark
Names = .Fields("SurName").Value & " " & .Fields("FirstName").Value & " " & .Fields("OtherNames").Value
f.Text = .Fields("RecordCount").Value
f.SubItems(1) = Names
If IsDate(.Fields("BirthDate").Value) Then
f.SubItems(5) = DateDifference
Else
f.SubItems(5) = ""
End If
i = i + 1
End If
When I try to run the application I get errors at:
(a) f.SubItems(1) = Names - "Value of type 'String' cannot be converted to 'System.Windows.Forms.ListViewItem.ListViewSubItem '"
(b) f.SubItems(5) = DateDifference - "Value of type 'Integer' cannot be converted to 'System.Windows.Forms.ListViewItem.ListViewSubItem '"
(c) f.SubItems(5) = "" - "Value of type 'String' cannot be converted to 'System.Windows.Forms.ListViewItem.ListViewSubItem '"
I need help because I ve tried to change to other variable values without success
Patrick