I have the following code:
It repeats exactly as is multiple times with the exception of "listRelations" changes to one of many other different object names based on the select case at the time.
I was wondering, is there a way to put this all in one subroutine and have the object acted on changed based on string parameters passed in?
Code:
Select Case localType
Case "Relations"
i = 0
For j = 0 To Me.listRelations.Count - 1
li.SubItems.Add(New ListViewItem.ListViewSubItem())
li.Text = Me.listRelations.Item(j).Name
i += 1
li.SubItems(i).Text = Me.listRelations.Item(j).Relation
'Copy listview item, attempt to store into array.
li_copy = TryCast(li.Clone(), ListViewItem)
If li_copy Is Nothing Then
MessageBox.Show("There was an error inserting record " & _
(ItemCount + 1).ToString & _
" into the list. It contains invalid data or is empty.", _
My.Application.Info.Title, _
MessageBoxButtons.OK, _
MessageBoxIcon.Error)
Continue For
Else
ReDim Preserve aryItems(ItemCount)
aryItems(ItemCount) = li_copy
End If
ItemCount += 1
'Reset values for populating with next record.
li.SubItems.Clear()
li.Text = ""
li_copy = Nothing
i = 0
Next j
...
It repeats exactly as is multiple times with the exception of "listRelations" changes to one of many other different object names based on the select case at the time.
I was wondering, is there a way to put this all in one subroutine and have the object acted on changed based on string parameters passed in?