[VB.NET] String to object

Soldato
Joined
12 Jun 2005
Posts
5,361
Hi there,

I have a string which refers to a name of an object on my form.

How do i convert the string to an object....if that makes sense.

Thanks.
 
I am trying to create a class which i could easily transfer to another application and since there doesn't seem to be control arrays, i need to construct the name with an increamenting number on the end.

Thanks.
 
Yeah, sure.

Basically, I current have 5 combobox boxes on my form, all with the same list of options. When i select an option in any of the 5 comboboxes, it takes that option off the four other combo boxes.

Basically, what i want to be able to do, is create a class where i pass in the combobox that just had an option selected and the number of combo boxes and it update all the other combo boxes on the form.

Currently, i have it working where i pass in the combobox that just had an option selected and a list of the comboboxes.

Here it is:

Code:
    Private Sub BoxSelected(ByVal SelectedCombo As ComboBox, ByVal clist As List(Of ComboBox))

        Dim a As Integer
        Dim startValues As New List(Of String)
        Dim ComboList As New List(Of Object)

        For Each Item As Object In clist
            If Item.Tag <> SelectedCombo.Tag Then
                ComboList.Add(Item)
                startValues.Add(Item.SelectedItem)
                Item.Items.Clear()
            End If
        Next

        For Each Item As String In sList
            If Item <> SelectedCombo.SelectedItem And Not startValues.Contains(Item) Then
                For Each Obj As Object In ComboList
                    Obj.Items.Add(Item)
                Next
            End If
        Next

        sChanged = False

        a = 0

        For Each Item As String In startValues
            If Item <> "" Then ComboList(a).Items.Add(Item)
            ComboList(a).SelectedItem = startValues(a)
            a += 1
        Next

    End Sub
 
Back
Top Bottom