VBA ComboBox Populated with multiple classes
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone
This is not really an Autodesk question, but it is something I'd like to integrate into Inventor so I am going to ask it anyway...
I am trying to create, on a userform, 2 comboboxes for steel sections.
Box 1 will be used to select between FB, Angles, Channels etc. And then box 2 will be the different available sizes for what ever sections is selected.
Box 1 list is populated using .AddItem method and Box 2 is populated using a class list.
Getting to switch between classes for Box 2 is fairly simple, and I am able to retrieve the correct values from my classes for each connected class.
However the problem comes in after I have done 2 or 3 selections, all of a sudden the returned values no longer update.
I have gone through my code and I cannot see where the problem occurs.
Below is my code:
Option Explicit
Dim WithEvents objFB As cls_Section_FB
Dim WithEvents objL As cls_Section_L
Dim WithEvents objC As cls_Section_C
Private Sub UserForm_Initialize()
With cmb_Sections
.AddItem "FB"
.AddItem "C"
.AddItem "L"
End With
End Sub
Private Sub cmb_Sections_Change()
cmbFlange.Clear
If cmb_Sections = "FB" Then
Set objFB = New cls_Section_FB
Set objFB.ListControl = Me.cmbFlange
Set objFB.m_cmb_Section = Me.cmbFlange
ElseIf cmb_Sections = "L" Then
Set objL = New cls_Section_L
Set objL.ListControl = Me.cmbFlange
Set objL.m_cmb_Section = Me.cmbFlange
ElseIf cmb_Sections = "C" Then
Set objC = New cls_Section_C
Set objC.ListControl = Me.cmbFlange
Set objC.m_cmb_Section = Me.cmbFlange
End If
End Sub
Private Sub objL_SectionCalc()
With objL
lblHeight = .section_Height
lblR1 = .section_R1
lblR2 = .section_R2
lblTF = .section_TFlange
lblTW = .section_TWeb
lblWidth = .section_Width
lblName = .section_Name
End With
End Sub
Private Sub objFB_SectionCalc()
With objFB
lblHeight = .section_Height
lblWidth = .section_Width
lblName = .section_Name
lblR1 = 0
lblR2 = 0
lblTF = 0
lblTW = 0
End With
End Sub
Private Sub objC_SectionCalc()
With objC
lblHeight = .section_Height
lblR1 = .section_R1
lblR2 = .section_R2
lblTF = .section_TFlange
lblTW = .section_TWeb
lblWidth = .section_Width
lblName = .section_Name
End With
End Sub
Thanks