Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
 
TitleUse a Select Case statement to display multiple instances of a form given its name
Keywordsform, form name, show form
CategoriesControls, Software Engineering
 
Use a Select Case statement to decide which kind of form to create.

This program has the advantages of simplicity and that it allows multiple instances of the forms. It has the disadvantage that it requires a potentially large Select statement.

 
' Display the named form.
Private Sub cmdShowForm_Click()
Dim frm As Form

    Select Case txtFormName.Text
        Case "Form2"
            Set frm = New Form2
        Case "Form3"
            Set frm = New Form3
        Case Else
            MsgBox "Unknown form name"
            Exit Sub
    End Select
    
    frm.Show
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated