Results 1 to 3 of 3

Thread: How to show a form at run-time?

  1. #1

    Thread Starter
    New Member
    Join Date
    May 1999
    Posts
    2

    Post

    Hi All,

    This sounds simple, but I am still stumbling with it. My question is, how do I show a form, let's say "form1" at run-time if I found out the name of the form as "form1" at run-time. I know at design-time, you just say - form1.show.

    I would appreciate it greatly if someone could help me out.

    Thanx
    Nabin

  2. #2
    PowerPoster
    Join Date
    Jul 1999
    Posts
    5,923

    Post

    I think you are somewhat confused. what you wrote e.g Form1.Show is how you show a form at runtime. Type it in a code window (e.g. Command1_Click)

    Regards,

    ------------------
    - Chris
    [email protected]
    If it ain't broke - don't fix it

  3. #3

    Thread Starter
    New Member
    Join Date
    May 1999
    Posts
    2

    Post

    Well, I may not have worded correctly, but anyway, I found a solution browsing through VB Forums. Thanx to Aaron Young, this is his solution.

    Private Sub Command1_Click() LoadForm "Form3", True
    End Sub

    Sub LoadForm(ByVal Formname As String, Optional ByVal bShow As Boolean = False) Dim iIndex As Integer
    'Add the Form to the Forms Collection
    '>>> Formname MUST exist to add it to the 'collection <<<
    Forms.Add Formname
    'Find the Index of the Form we just added For iIndex = 0 To Forms.Count - 1
    If Forms(iIndex).Name = Formname Then Exit For
    Next

    If iIndex < Forms.Count Then
    'If the Form Existed Then Load it Load Forms(iIndex)
    If bShow Then Forms(iIndex).Show
    End If
    End Sub

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