Results 1 to 23 of 23

Passing combobox value to custom class

Threaded View

  1. #1
    Forum Contributor
    Join Date
    01-15-2010
    Location
    Jhb, South Africa
    MS-Off Ver
    2007, 2010, 2016
    Posts
    275

    Passing combobox value to custom class

    Hi all,

    I have created a class that populates a combobox list with my values for reuase, this class is then initialised in a user form and linked to a combobox1.

    However, I'm trying to generate a couple of properties from the selection of this list made by the user.

    So, to try and explain again, the list is created by a class, the user clicks on the drop down and selects a value in the list, I then wnat the class to know which value is selected so that I can do calculations in the class.

    How do I do this?

    Here is my code:

    'Class code for: cls_combobox_FlangeSection
    
    Option Explicit
    
    Public m_ctlListControl As MSForms.Control
    Public m_asListItems As Variant
    Public WithEvents m_cmbFlangeSection As MSForms.ComboBox
    
    Private Sub Class_Initialize()
        m_asListItems = _
            Array("FB 012.0 x 03.0", "FB 020.0 x 03.0", "FB 020.0 x 05.0", "FB 020.0 x 06.0", "FB 020.0 x 08.0", "FB 020.0 x 10.0", "FB 025.0 x 03.0", "FB 025.0 x 04.5", "FB 025.0 x 05.0", "FB 025.0 x 06.0", "FB 025.0 x 08.0", "FB 025.0 x 10.0", "FB 025.0 x 12.0", "FB 030.0 x 04.5", "FB 030.0 x 05.0", "FB 030.0 x 06.0", "FB 030.0 x 08.0", "FB 030.0 x 10.0", "FB 030.0 x 12.0", "FB 035.0 x 05.0", _
                "FB 040.0 x 04.5", "FB 040.0 x 05.0", "FB 040.0 x 06.0", "FB 040.0 x 08.0", "FB 040.0 x 10.0", "FB 040.0 x 12.0", "FB 040.0 x 16.0", "FB 040.0 x 20.0", "FB 040.0 x 25.0", "FB 047.6 x 05.0", "FB 050.0 x 05.0", "FB 050.0 x 06.0", "FB 050.0 x 08.0", "FB 050.0 x 10.0", "FB 050.0 x 12.0", "FB 050.0 x 16.0", "FB 050.0 x 20.0", "FB 050.0 x 25.0", "FB 060.0 x 06.0", "FB 060.0 x 08.0", _
                "FB 060.0 x 10.0", "FB 060.0 x 12.0", "FB 060.0 x 16.0", "FB 060.0 x 20.0", "FB 060.0 x 25.0", "FB 060.0 x 30.0", "FB 065.0 x 06.0", "FB 065.0 x 08.0", "FB 065.0 x 10.0", "FB 065.0 x 12.0", "FB 065.0 x 16.0", "FB 065.0 x 20.0", "FB 065.0 x 25.0", "FB 070.0 x 06.0", "FB 070.0 x 08.0", "FB 070.0 x 10.0", "FB 070.0 x 12.0", "FB 070.0 x 16.0", "FB 070.0 x 20.0", "FB 080.0 x 06.0", _
                "FB 080.0 x 08.0", "FB 080.0 x 10.0", "FB 080.0 x 12.0", "FB 080.0 x 16.0", "FB 080.0 x 20.0", "FB 080.0 x 25.0", "FB 080.0 x 30.0", "FB 080.0 x 40.0", "FB 090.0 x 06.0", "FB 090.0 x 08.0", "FB 090.0 x 10.0", "FB 090.0 x 12.0", "FB 090.0 x 16.0", "FB 090.0 x 20.0", "FB 090.0 x 25.0", "FB 100.0 x 06.0", "FB 100.0 x 08.0", "FB 100.0 x 10.0", "FB 100.0 x 12.0", "FB 100.0 x 16.0", _
                "FB 100.0 x 20.0", "FB 100.0 x 25.0", "FB 100.0 x 30.0", "FB 100.0 x 40.0", "FB 100.0 x 50.0", "FB 110.0 x 06.0", "FB 110.0 x 08.0", "FB 110.0 x 10.0", "FB 110.0 x 12.0", "FB 130.0 x 08.0", "FB 130.0 x 10.0", "FB 130.0 x 12.0", "FB 130.0 x 16.0", "FB 130.0 x 20.0", "FB 130.0 x 25.0", "FB 150.0 x 08.0", "FB 150.0 x 10.0", "FB 150.0 x 12.0", "FB 150.0 x 16.0", "FB 150.0 x 20.0", _
                "FB 150.0 x 25.0", "FB 150.0 x 30.0", "FB 180.0 x 10.0", "FB 180.0 x 12.0", "FB 180.0 x 16.0", "FB 180.0 x 20.0", "FB 180.0 x 25.0", "FB 200.0 x 10.0", "FB 200.0 x 12.0", "FB 200.0 x 16.0", "FB 200.0 x 18.0", "FB 200.0 x 20.0", "FB 200.0 x 25.0", "FB 200.0 x 30.0", "FB 250.0 x 10.0", "FB 250.0 x 12.0", "FB 250.0 x 16.0", "FB 250.0 x 18.0", "FB 250.0 x 20.0", "FB 250.0 x 25.0", _
                "FB 250.0 x 30.0", "FB 300.0 x 10.0", "FB 300.0 x 12.0", "FB 300.0 x 16.0", "FB 300.0 x 18.0", "FB 300.0 x 20.0", "FB 300.0 x 25.0", "FB 300.0 x 30.0", "FB 300.0 x 35.0", "FB 300.0 x 40.0", "FB 300.0 x 45.0", "FB 300.0 x 50.0", "FB 300.0 x 55.0", "FB 300.0 x 65.0", _
                "eqL 025.0 x 025.0 x 02.5", "eqL 025.0 x 025.0 x 03.0", "eqL 025.0 x 025.0 x 04.0", "eqL 025.0 x 025.0 x 05.0", "eqL 030.0 x 030.0 x 03.0", "eqL 030.0 x 030.0 x 04.0", "eqL 030.0 x 030.0 x 05.0", "eqL 040.0 x 040.0 x 02.5", "eqL 040.0 x 040.0 x 03.0", "eqL 040.0 x 040.0 x 04.0", "eqL 040.0 x 040.0 x 05.0", "eqL 040.0 x 040.0 x 06.0", "eqL 045.0 x 045.0 x 03.0", "eqL 045.0 x 045.0 x 04.0", _
                "eqL 045.0 x 045.0 x 05.0", "eqL 045.0 x 045.0 x 06.0", "eqL 050.0 x 050.0 x 03.0", "eqL 050.0 x 050.0 x 04.0", "eqL 050.0 x 050.0 x 05.0", "eqL 050.0 x 050.0 x 06.0", "eqL 050.0 x 050.0 x 08.0", "eqL 060.0 x 060.0 x 04.0", "eqL 060.0 x 060.0 x 05.0", "eqL 060.0 x 060.0 x 06.0", "eqL 060.0 x 060.0 x 08.0", "eqL 060.0 x 060.0 x 10.0", "eqL 070.0 x 070.0 x 06.0", "eqL 070.0 x 070.0 x 08.0", _
                "eqL 070.0 x 070.0 x 10.0", "eqL 080.0 x 080.0 x 06.0", "eqL 080.0 x 080.0 x 08.0", "eqL 080.0 x 080.0 x 10.0", "eqL 080.0 x 080.0 x 12.0", "eqL 090.0 x 090.0 x 06.0", "eqL 090.0 x 090.0 x 08.0", "eqL 090.0 x 090.0 x 10.0", "eqL 090.0 x 090.0 x 12.0", "eqL 100.0 x 100.0 x 08.0", "eqL 100.0 x 100.0 x 10.0", "eqL 100.0 x 100.0 x 12.0", "eqL 100.0 x 100.0 x 15.0", "eqL 120.0 x 120.0 x 08.0", _
                "eqL 120.0 x 120.0 x 10.0", "eqL 120.0 x 120.0 x 12.0", "eqL 120.0 x 120.0 x 15.0", "eqL 150.0 x 150.0 x 10.0", "eqL 150.0 x 150.0 x 12.0", "eqL 150.0 x 150.0 x 15.0", "eqL 150.0 x 150.0 x 18.0", "eqL 200.0 x 200.0 x 16.0", "eqL 200.0 x 200.0 x 18.0", "eqL 200.0 x 200.0 x 20.0", "eqL 200.0 x 200.0 x 24.0", _
                "uneqL 065.0 x 050.0 x 06.0", "uneqL 065.0 x 050.0 x 08.0", "uneqL 075.0 x 050.0 x 06.0", "uneqL 075.0 x 050.0 x 08.0", "uneqL 080.0 x 060.0 x 06.0", "uneqL 080.0 x 060.0 x 08.0", "uneqL 090.0 x 065.0 x 06.0", "uneqL 090.0 x 065.0 x 08.0", "uneqL 090.0 x 065.0 x 10.0", "uneqL 095.0 x 065.0 x 06.0", "uneqL 095.0 x 065.0 x 08.0", "uneqL 095.0 x 065.0 x 10.0", _
                "uneqL 100.0 x 065.0 x 08.0", "uneqL 100.0 x 065.0 x 10.0", "uneqL 100.0 x 075.0 x 06.0", "uneqL 100.0 x 075.0 x 08.0", "uneqL 100.0 x 075.0 x 10.0", "uneqL 100.0 x 075.0 x 12.0", "uneqL 125.0 x 075.0 x 08.0", "uneqL 125.0 x 075.0 x 10.0", "uneqL 125.0 x 075.0 x 12.0", "uneqL 150.0 x 075.0 x 10.0", "uneqL 150.0 x 075.0 x 12.0", "uneqL 150.0 x 075.0 x 15.0", _
                "uneqL 150.0 x 090.0 x 10.0", "uneqL 150.0 x 090.0 x 12.0", "uneqL 150.0 x 090.0 x 15.0")
                
    End Sub
    
    Private Sub Class_Terminate()
        Set m_ctlListControl = Nothing
    End Sub
    
    Public Property Get ListControl() As MSForms.Control
        Set ListControl = m_ctlListControl
    End Property
    
    Public Property Set ListControl(ctlListControl As MSForms.Control)
        Select Case TypeName(ctlListControl)
            Case "ListBox", "ComboBox"
                Set m_ctlListControl = ctlListControl
                m_ctlListControl.List = m_asListItems
            Case Else
                ' up to you - maybe raise an error?
        End Select
    End Property
    'Form code:
    
    Dim oList As cls_combobox_FlangeSection
    
    Private Sub UserForm_Initialize()
        Set oList = New cls_combobox_FlangeSection
        Set oList.ListControl = Me.ComboBox1
    End Sub
    Last edited by Jacques Grobler; 07-05-2012 at 03:15 AM.
    Jacques


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1