Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Opening named forms in VB4 (32 bit) code 2

Status
Not open for further replies.

Buldoo

Programmer
Aug 17, 2000
2
GB
I am working on a project that will require me to give the user a list of reports, some of which have a form associated with them. If they select one of the reports with a form, then I need to be able to open the form.

As the list of reports will be different from system to system / user to user, I have to be able to open the forms without hard coding the names.

According to the VB4(32 bit) help, 'You can use a Form's Name property with the Dim statement at Run-Time to create other instances of the form...', but I cannot find any examples as to how this is done.
 
There is a way to do this, I can't remember how. But, I have done it before. I'll have to get back to you on the specifics of it when I find the program I've used it in. [sig]<p> <br><a href=mailto: > </a><br><a href= > </a><br><b>FYI</b>...Jack <b>was</b> nimble, Jack <b>was</b> quick...until he got 3rd degree burns when his pants caught on fire.[/sig]
 
[tt]
Dim frm As New Form1
frm.Show
[/tt]
Will create and display a new copy of form1. It sounds like your might need to have more then one of a form open at a time. I suggest using an array like this...
[tt]
Dim frm(4) As New Form1, i As Integer
For i = 0 To 4
'Give each form it's own caption and position
frm(i).Caption = &quot;Window &quot; & i
frm(i).Top = frm(i).Top + (i * 120)
frm(i).Left = frm(i).Left + (i * 120)
'Show the form
frm(i).Show
Next
[/tt]
You probally wouldn't want to open them all at once but it's an easy matter to keep track of how many are open and extend the array each time you need a new form.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top