Results 1 to 13 of 13

Thread: duplicating forms at runtime RESOLVED

Hybrid View

  1. #1
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: duplicating forms at runtime

    Code:
    Set frmComputerCards1 = New frmComputerCards
    Load frmComputerCards1
    frmComputerCards1.Caption = "Computer Player 1"
    frmComputerCards1.txtUsername.Text = "Woka"
    frmComputerCards1.Show
    Woka

  2. #2
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: duplicating forms at runtime

    Keep in mind that "frmComputerCards1" is a form object local to whatever sub/func you are creating the new instance of the form in.

    It will not be the name of the form throughout the program - right?

    We always use the FORMS() collection to access the forms we "duplicate"...

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  3. #3
    Super Moderator Wokawidget's Avatar
    Join Date
    Nov 2001
    Location
    Headingly Occupation: Classified
    Posts
    9,632

    Re: duplicating forms at runtime

    I would write this as:
    Code:
    Dim frmNew    As frmComputerCards
       Set frmNew = New frmComputerCards
       Load frmNew
       With frmNew
          .Caption = "Woof"
          .txtUsername.Text = "Woka"
          .Show
       End With
       Set frmNew = Nothing
    szlamany, yup, you are right. frmNew will only be a local object name in the confines of the funtion you have: Dim frmNew As, in.

    Woof

  4. #4

    Thread Starter
    Member
    Join Date
    Feb 2005
    Posts
    51

    Re: duplicating forms at runtime

    Thanks that helped a lot. I got 1 last question related to this topic. If I want the user to be able to choose between 1 to 8 computer players. Whats the easiest way to load the forms?

  5. #5
    MS SQL Powerposter szlamany's Avatar
    Join Date
    Mar 2004
    Location
    Connecticut
    Posts
    18,263

    Re: duplicating forms at runtime

    Use either method - FORMS.ADD("formname") or the .SHOW/LOAD method with a FORM object.

    But then in some GLOBAL array you could store the (FORMS.COUNT-1) value of the newly added form.

    You can refer to the form by FORMS(x).whatever with x being the value of the newly added form.

    *** Read the sticky in the DB forum about how to get your question answered quickly!! ***

    Please remember to rate posts! Rate any post you find helpful - even in old threads! Use the link to the left - "Rate this Post".

    Some Informative Links:
    [ SQL Rules to Live By ] [ Reserved SQL keywords ] [ When to use INDEX HINTS! ] [ Passing Multi-item Parameters to STORED PROCEDURES ]
    [ Solution to non-domain Windows Authentication ] [ Crazy things we do to shrink log files ] [ SQL 2005 Features ] [ Loading Pictures from DB ]

    MS MVP 2006, 2007, 2008

  6. #6

    Thread Starter
    Member
    Join Date
    Feb 2005
    Posts
    51

    Resolved Re: duplicating forms at runtime

    Thanks everybody for your help.

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