Convert String, To Object, Then To Form

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • devonknows
    New Member
    • Nov 2006
    • 137

    Convert String, To Object, Then To Form

    Hi, The problem im having is, Im creating a user control. The user (via the Property Page's) will set his own menu titles, and the choose a form of which that title links to. If that makes sense.

    So the form names are stored in string data, how can i convert it from a string to an object or to a form so that when someone clicks on the title the form will show. Is there a way to loop though form names?

    But i dont want to have to add and if-then-else statement or select-case statement for every form i have.
    Example:
    Code:
    if  txtFormName.Text = "frmMain" then
    	frmMain.show
    end if
    Any help again would be appreciated
    Kind Regards
    Devon
  • Killer42
    Recognized Expert Expert
    • Oct 2006
    • 8429

    #2
    What version of Vb is this in?

    Comment

    • devonknows
      New Member
      • Nov 2006
      • 137

      #3
      Originally posted by Killer42
      What version of Vb is this in?
      The version im using is VB6 (Microsoft Visual Studio 6)

      Kind Regards
      Devon

      Comment

      • devonknows
        New Member
        • Nov 2006
        • 137

        #4
        Originally posted by devonknows
        The version im using is VB6 (Microsoft Visual Studio 6)

        Kind Regards
        Devon
        Just bumping this up
        any help would be appreciated

        Kind Regards
        Devon

        Comment

        • Killer42
          Recognized Expert Expert
          • Oct 2006
          • 8429

          #5
          Try looping through the Forms collection until you hit the one with the required name. Or was it caption... whatever.

          Comment

          • devonknows
            New Member
            • Nov 2006
            • 137

            #6
            Originally posted by Killer42
            Try looping through the Forms collection until you hit the one with the required name. Or was it caption... whatever.
            i tried what you asked but wen i used

            dim frm as Form
            for each frm in forms
            if frm.name = arrFrm(Index)
            next

            all it does is it searches through the forms that are already open/loaded
            but with the amount of forms that i have it would be inpractical and it would use laods of resources loading them all.

            is there anyway to loop through the forms that arn't open/loaded?

            Kind Regards
            Devon

            Comment

            • Killer42
              Recognized Expert Expert
              • Oct 2006
              • 8429

              #7
              I don't know the answer to that, but I wonder whether you could work around it by maintaining your own array or collection, updating it in the forms' load/unload event procedures. given the need to identify forms that aren't currently loaded (and presumably may never have been loaded yet) I think you'd need to load up the complete array/collection at startup. Then use the event procedures to maintain a current status of each form.

              Granted it's a pretty ugly way of goling about it, but it's the best I can come up with at the moment. Does it sound doable? I don't recall enough about the prior discussion to say one way or the other.

              Comment

              • Killer42
                Recognized Expert Expert
                • Oct 2006
                • 8429

                #8
                Oops!

                Just re-read some of the earlier messages and it looks as though my suggestion will be no help whatsoever. Sorry about that.

                Can't think of anything better right now.

                Comment

                Working...