Access a form, using a string literal?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Gerrit Snel

    #1

    Access a form, using a string literal?

    We have a question but we're in doubt if it's even possible or not.

    The question is as follows:

    Is it possible to access a form using a string literal, and if so yes?

    We want to use something like this (don't mind the syntax as it obviously
    doesn't work):

    Form("Form1") frm = ("Form1")GetFor m("Form1");

    So we're able to access all the properties and methods of Form1 and not
    just the methods and properties of the base class "Form".

    Any help on this one is greatly appreciated!

    Gerrit


  • saucer

    #2
    RE: Access a form, using a string literal?

    I would think you could try Reflection, for example, see


    but obviouly, you will lose the benefits of static type checking, code will
    be hard to debug and the performance may even suffer

    Anything else close will be something like dynamic identifiers in the
    just-released VB 9 Linq CTP

    "Gerrit Snel" wrote:
    [color=blue]
    > We have a question but we're in doubt if it's even possible or not.
    >
    > The question is as follows:
    >
    > Is it possible to access a form using a string literal, and if so yes?
    >
    > We want to use something like this (don't mind the syntax as it obviously
    > doesn't work):
    >
    > Form("Form1") frm = ("Form1")GetFor m("Form1");
    >
    > So we're able to access all the properties and methods of Form1 and not
    > just the methods and properties of the base class "Form".
    >
    > Any help on this one is greatly appreciated!
    >
    > Gerrit
    >
    >
    >[/color]

    Comment

    • Ciaran

      #3
      Re: Access a form, using a string literal?

      Nothing like that will really work. I assume you are talking about running
      code typed at runtime or something.
      At design time you could just do:

      Form1 frm = new Form1

      That would give you access to all the properties and methods.

      HTH

      Ciaran


      "Gerrit Snel" <gsnel_geentroe p@hotmail.com> wrote in message
      news:%236QugOpI GHA.2472@TK2MSF TNGP10.phx.gbl. ..[color=blue]
      > We have a question but we're in doubt if it's even possible or not.
      >
      > The question is as follows:
      >
      > Is it possible to access a form using a string literal, and if so yes?
      >
      > We want to use something like this (don't mind the syntax as it obviously
      > doesn't work):
      >
      > Form("Form1") frm = ("Form1")GetFor m("Form1");
      >
      > So we're able to access all the properties and methods of Form1 and not
      > just the methods and properties of the base class "Form".
      >
      > Any help on this one is greatly appreciated!
      >
      > Gerrit
      >[/color]


      Comment

      • Gerrit

        #4
        Re: Access a form, using a string literal?

        OK, thank you all
        I try something else i think

        "Ciaran" <ciaran@theodon nells.plus.com> schreef in bericht
        news:43d95386$0 $6994$ed2619ec@ ptn-nntp-reader02.plus.n et...[color=blue]
        > Nothing like that will really work. I assume you are talking about running
        > code typed at runtime or something.
        > At design time you could just do:
        >
        > Form1 frm = new Form1
        >
        > That would give you access to all the properties and methods.
        >
        > HTH
        >
        > Ciaran
        >
        >
        > "Gerrit Snel" <gsnel_geentroe p@hotmail.com> wrote in message
        > news:%236QugOpI GHA.2472@TK2MSF TNGP10.phx.gbl. ..[color=green]
        >> We have a question but we're in doubt if it's even possible or not.
        >>
        >> The question is as follows:
        >>
        >> Is it possible to access a form using a string literal, and if so yes?
        >>
        >> We want to use something like this (don't mind the syntax as it obviously
        >> doesn't work):
        >>
        >> Form("Form1") frm = ("Form1")GetFor m("Form1");
        >>
        >> So we're able to access all the properties and methods of Form1 and not
        >> just the methods and properties of the base class "Form".
        >>
        >> Any help on this one is greatly appreciated!
        >>
        >> Gerrit
        >>[/color]
        >
        >[/color]


        Comment

        Working...