Home All Groups Group Topic Archive Search About
Author
4 May 2007 11:55 AM
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

*** Sent via Developersdex http://www.developersdex.com ***

Author
5 May 2007 10:07 AM
PitG
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...
--
PG


Show quoteHide quote
"schapopa" wrote:

> 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
>
> *** Sent via Developersdex http://www.developersdex.com ***
>