I'm creating a dynamic form using VB6 where the number of labels and combo boxes is dependent on the number of levels.
I've figured out how to make the dynamic array for the combo boxes but I can't connect a _Click() sub to the new "OK" button I've created.
In addition, in the new "OK" sub that I would like, I want to populate an array called rankLayers() with the selections from the combo boxes made in the FormLoad() Sub.
Any and all help and suggestions would be greatly appreciated !
Private Sub Form_Load() 'Variable defintions---------------- Dim i As Integer: Dim j As Integer: Dim rank As Integer: Dim mL As Integer: Dim objLabel As label: Dim objOK As CommandButton: Dim objCmb(0 To 9) As ComboBox: Me.height = 2000 + 500 * (maxlevels + 2) Me.width = 4800 For i = 0 To maxlevels - 1 Set objLabel = frmRankStrata.Controls.add("VB.Label", "lblgm_" & CStr(i), frmRankStrata) With objLabel .Caption = "Strata: " & CompareLayers(i).GM .Left = 100 .Top = 1320 + 500 * i .width = 3500 .Visible = True End With Set objCmb(i) = frmRankStrata.Controls.add("vb.ComboBox", "cboRank" & CStr(i), frmRankStrata) With objCmb(i) .Visible = True .Left = 2500 .Top = 1320 + 500 * i .width = 600 End With For k = 0 To maxlevels - 1 rank = k + 1 objCmb(i).AddItem CStr(rank) Next k If i = maxlevels - 1 Then Set objOK = frmRankStrata.Controls.add("vb.CommandButton", "cmdOK", frmRankStrata) With objOK .Visible = True .Left = 2500 .Top = objCmb(i).Top + 500 .Caption = "OK" End With End If Next i End Sub Private Sub cmdOK_Click() Dim k As Integer: ReDim ctrls(maxlevels) ReDim rankLayers(maxlevels): For k = 0 To maxlevels - 1 rankLayers(k) = CInt(objCmb(k).SelText) Debug.Print (rankLayers(k)) Next k
This post has been edited by modi123_1: 09 June 2014 - 10:46 AM
Reason for edit:: please use the 'code' button in the editor