Instance of the form

S

schapopa

I am trying to call instance of the form from code.
So I have forms frm1, frm2, frm3
I can open them: frm1.definstance.show, frm2.definstance.show...
I want to create something like this:

sub openform(formname)
formname.definstance.show
end sub

I don't know what is formname here,
dim formname as ??
I hope I explained that.
Cheers
Schapopa
 
G

Guest

I hope i understud your question right...
here an examplecode not using name but the instance istself:

Public Class Class1

Private F1 As New Form1
Private F2 As New Form2
Private F3 As New Form3

' you may simple call the instances to do what you expect
Public Sub Main()
F1.Show()
F2.Show()
F3.Show()
End Sub

' or handling this calling for some other reasons with a special method
Public Sub Doit()
OpenForm(F1)
OpenForm(F2)
OpenForm(F3)
End Sub

Public Sub OpenForm(ByVal instance As System.Windows.Forms.Form)
' ....
instance.Show()
' ....
End Sub
End Class

if this is a much to simple interpretation for your case - try it with the
CallByName method...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top