Results 1 to 6 of 6

Thread: How to show / showdialog form thru a string

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2003
    Posts
    784

    How to show / showdialog form thru a string

    Dear All,
    How to show / showdialog form thru a string,
    eg:

    Dim mForm as String = "Form1"

    How to show it?

    Regards
    Winanjaya

  2. #2
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    like this ....
    VB Code:
    1. Dim mForm As String = "Form3"
    2.         Dim f As Form = DirectCast(GetType(Form).InvokeMember(mForm, Reflection.BindingFlags.CreateInstance, Nothing, Nothing, Nothing), Form)
    3.         f.Show()
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Nov 2003
    Posts
    784
    Hi.. it works but all of objects (textbox, label, checkbox .. etc) not shown .. why? ..

  4. #4
    Frenzied Member dynamic_sysop's Avatar
    Join Date
    Jun 2003
    Location
    Ashby, Leicestershire.
    Posts
    1,142
    sorry i forgot to use the correct type , you should be using Type.GetType , not GetType. specifying the application name and a dot ( . ) and the form name as a string ( eg: Application1.Form1 )
    eg:
    VB Code:
    1. '/// use Type.GetType(appName & mForm)
    2.         Dim appName As String = Application.ProductName & "."
    3.         Dim mForm As String = "Form3"
    4.         Dim f As Form = DirectCast(Type.GetType(appName & mForm).InvokeMember(mForm, Reflection.BindingFlags.CreateInstance, Nothing, Nothing, Nothing), Form)
    5.         f.Show()
    ~
    if a post is resolved, please mark it as [Resolved]
    protected string get_Signature(){return Censored;}
    [vbcode][php] please use code tags when posting any code [/php][/vbcode]

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Scooooooore!

    dynamic_sysop - Dude! thank you very much for that little piece of code. It is EXACTLY what I needed. I've been knocking myself out on how to do just that. Once I got my Application Name set right (I had a space in it originally) it worked perfectly.

    Danke a million times over.

    Tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  6. #6
    PowerPoster
    Join Date
    Dec 2003
    Location
    Bristol, England (but heart is in Virginia)
    Posts
    2,949

    Re: Scooooooore!

    Originally posted by techgnome
    dynamic_sysop - Dude! thank you very much for that little piece of code. It is EXACTLY what I needed. I've been knocking myself out on how to do just that. Once I got my Application Name set right (I had a space in it originally) it worked perfectly.

    Danke a million times over.

    Tg
    Hi techgnome,

    Could you please elaborate on "Once I got my Application Name set right "

    Do I understand you to say that you can create an instance of a form from another application?
    Taxes
    The more I learn about VB.NET the more I like dBaseIII Plus

    The foregoing, whilst believed to be correct, is given without guarantee as to it's accuracy and entirely without recourse. You are required to decide for yourself whether or not it is suitable for your purposes and no liability for loss of any nature can be entertained.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width