Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have the following 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?

Posted

You may want to look into this method:

this.Controls.Find(string,true);

you will then need to pass in the exact name, not just part of it.

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

Posted

Something like this should work, no?

public void doWork<T>(IList<T> theList)
{

}

 

Public Sub doWork(Of T)(theList As IList(Of T))
   
End Sub

~Nate�

___________________________________________

Please use the [vb]/[cs] tags on posted code.

Please post solutions you find somewhere else.

Follow me on Twitter here.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...