Results 1 to 2 of 2

Thread: creating forms using strings

  1. #1

    Thread Starter
    Registered User Nucleus's Avatar
    Join Date
    Apr 2001
    Location
    So that's what you are up to ;)
    Posts
    2,530

    creating forms using strings

    anyone know a way to create a form based on a string?

    eg.

    Private Sub Command1_Click()
    Dim f As Form

    Set f = CreateObject(App.Name & ".form2")
    f.Show
    End Sub

    I want this to be dynamic so that the same code will create different forms under different circumstances without a long winded if then statement like this:

    if integer = 1 then

    set form = new form1

    else if integer = 2 then

    set form = new form2

    elseif integer = 3 then

    set form = new form3

    else

    set form = new form4

    end if

  2. #2
    Frenzied Member Microbasic's Avatar
    Join Date
    Mar 2001
    Posts
    1,402
    Hello, Nucleus.

    Try something like this:

    VB Code:
    1. Private Sub Command1_Click()
    2.     Dim f As Form
    3.  
    4.     Set f = VB.Forms.Add("Form2")
    5.     f.Show
    6. End Sub


    MicroBasic
    Dragon Shadow Trainer

    There is no good or evil in the world...only programmers and fools .

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