This code will show you how to use forms in multi instances, meaning you can
create many instances of a control at runtime but yet only need create the form
once at design. To use this code you need:
2 Forms: - frmLaunch and frmMain
1 command Button on frmlaunch: - cmdNew
1 lable on frmMain: - lblNum
Paste the following code into frmLaunch:
Option Explicit
'//Define Variables for the form
Dim NewPage() As New frmMain
'//Define Variables for the Number of forms that have been opened
Public Pages As Integer
Private Sub cmdNew_Click()
'add one to the number of forms
Pages = Pages + 1
ReDim Preserve NewPage(Pages)
'set the new forms page number
NewPage(Pages).lblNum.Caption = Pages
'open a new page
NewPage(Pages).Show
'redimensionise the new page array
ReDim NewPage(Pages + 1) As New frmMain
End Sub
Comments