' This is ALL of the code under our main MDI form Option Explicit Dim strSide As String ' frmUnit is the MDI child ' It has 2 slider controls ' 1 wang image control ' 1 frame as container ' 3 lables Dim UnitForms() As New frmUnit Dim UnitNumber As Long Private Sub MDIForm_Click() UnitNumber = UnitNumber + 1 ReDim Preserve UnitForms(UnitNumber) As New frmUnit UnitForms(UnitNumber).Show End Sub Private Sub MDIForm_Load() Call MDIForm_Resize UnitNumber = 0 'Load our races list into our ' "Sides" Menu Me.mnuSideOption(1).Caption = StrConv(Race(1).Name, vbProperCase) ' Continue to load the list of our race Dim i As Integer For i = 2 To UBound(Race) ' Load our new dynamic sub menu Load mnuSideOption(i) ' Give it its caption mnuSideOption(i).Caption = StrConv(Race(i).Name, vbProperCase) ' Make it viewable mnuSideOption(i).Visible = True Next ' Setup our default selected side strSide = StrConv(mnuSideOption(1).Caption, vbUpperCase) ' Check off our default selected side mnuSideOption(1).Checked = True End Sub Private Sub MDIForm_Resize() Dim y As Long Dim i As Long For i = 1 To Forms.Count - 1 If Forms(i).MDIChild Then Forms(i).Move 0, y, ScaleWidth, 1350 y = y + 1350 End If Next End Sub Public Sub ResizeMe() ' Call the resize event Call MDIForm_Resize End Sub Private Sub mnuAircraft_Click() End Sub Private Sub mnuSelectedSide_Click() End Sub Private Sub MDIForm_Unload(Cancel As Integer) Dim i As Integer 'On Error Resume Next '' Unload all of our mdi children 'For i = 1 To UBound(UnitForms) ' ' Unload our unit form ' ' Set UnitForms(i) = Nothing 'Next Do While Not (Me.ActiveForm Is Nothing) Unload Me.ActiveForm Loop For i = 2 To mnuSideOption.Count - 1 Unload mnuSideOption(i) Next 'For i = 0 To mnuTypes.Count ' Unload mnuTypes(i) 'Next ReDim UnitForms(0) As New frmUnit ReDim Unit(0) As New kgUnit ReDim Race(0) As New kgRaces Set UnitForms(0) = Nothing Set Unit(0) = Nothing Set Race(0) = Nothing End Sub Private Sub mnuSideOption_Click(Index As Integer) Dim i As Integer For i = 1 To mnuSideOption.Count mnuSideOption(i).Checked = False Next mnuSideOption(Index).Checked = True strSide = StrConv(mnuSideOption(Index).Caption, vbUpperCase) ' Reload our units For i = 1 To mnuTypes.Count - 1 If mnuTypes(i).Checked Then ' Uncheck our unit type menu mnuTypes(i).Checked = False ' Reload our current unit list Call mnuTypes_Click(i) ' We can exit our loop now Exit For End If Next End Sub Private Sub mnuTypes_Click(Index As Integer) 'Me.Enabled = False Dim i As Integer ' Check to see if this menu already selected If mnuTypes(Index).Checked Then Exit Sub ' Uncheck all menus For i = 0 To mnuTypes.Count - 1 mnuTypes(i).Checked = False Next 'Check our currently selected menu mnuTypes(Index).Checked = True ' Show our pic to take up the screen ' and force our forms offscreen 'picFullScale.Visible = True ' Check to see if we have previously ' loaded unit forms If UnitNumber > 0 Then ' Unload previously loaded unit forms For i = 1 To UBound(UnitForms) If UnitForms(i).Visible Then UnitForms(i).Visible = False Unload UnitForms(i) ' Use this to check how many units ' are left (Debugging) UnitNumber = UnitNumber - 1 End If Next End If ' Convert our selected menu to ' the proper TEDClass for our units Dim strTEDClass As String Select Case mnuTypes(Index).Caption Case "&Commanders" strTEDClass = "COMMANDER" Case "&Jets" strTEDClass = "VTOL" Case "&Defenses" strTEDClass = "FORT" Case "&Kbots" strTEDClass = "KBOT" Case "&Plants" strTEDClass = "PLANT" Case "S&hips" strTEDClass = "SHIP" Case "&Specials" strTEDClass = "SPECIAL" Case "&Vehicles" strTEDClass = "TANK" Case "&Workers" strTEDClass = "CNSTR" End Select On Error Resume Next ' Default the unit number to 0 UnitNumber = 1 For i = 1 To UBound(Unit) 'If Err.Number <> 0 Then Exit For If Unit(i).TEDClass = strTEDClass Then ' Make sure this unit is for our ' checked side If Unit(i).Side = strSide Then If Me.Tag = "" Then Me.Tag = i ReDim Preserve UnitForms(UnitNumber) As New frmUnit 'Setup our unit index UnitForms(UnitNumber).intUnit = i 'UnitForms(i).Tag = Unit(i).Name & ".pcx" UnitForms(UnitNumber).lblUnitName.Caption = Unit(i).Name ' If Unit(i).Name = "Guardian" Then Stop UnitForms(UnitNumber).ImgEdit1.Image = Unit(i).UnitName & ".pcx" UnitForms(UnitNumber).ImgEdit1.Display UnitNumber = UnitNumber + 1 End If End If Next ' Loop and show all of our units For i = 1 To UnitNumber ' Show all of our forms UnitForms(UnitNumber).Show Next ' Call form resize Call MDIForm_Resize ' Check to see if we shoudl ' set focus to the first unit If Me.Tag <> "" Then UnitForms(Me.Tag).SetFocus Me.Tag = "" End If 'Set focus on the first unit form UnitForms(1).SetFocus 'picFullScale.Visible = False 'Me.Enabled = True DoEvents End Sub Private Sub picBorder_Resize() lblAIName.Move 0, 0, picBorder.Width, picBorder.Height + 1 End Sub