CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Apr 2001
    Posts
    3

    Convert string to form

    I am not sure about which category to put this in. Anyway, what I am trying to do is this. I have names of forms stored in a database and want to use these values to load the forms. In order to keep from hard coding anything in the program, I want to accept the string from the database, convert the string value to a form object, and then load the form. Then I can get the window handle, which is really why I am going through this song and dance to begin with. Any ideas, let me know.

    Thanks in advance,

    [email protected]


  2. #2
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Convert string to form

    This is Bruno solution to this matter.

    Use Add method of Forms collection:
    Forms.Add("Form1").Show
    You'll need VB6 SP3 for Forms.Add to work. Without SP3 it won't work when compiled.


    option Explicit
    private Sub Form_Click()
    Dim x as Form, strName as string
    strName = "Form1"
    set x = Forms.Add(strName)
    x.Show
    End Sub

    Hope it help you too
    Cesare Imperiali





    Special thanks to Lothar "the Great" Haensler. Come back soon, you Guru.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  3. #3
    Join Date
    Apr 2001
    Posts
    3

    Re: Convert string to form

    Well, I am running VB6 with SP4 and I can't get ths Forms.Add to work. I get error 424, object required. Any hints to make this work?


  4. #4
    Join Date
    Apr 2001
    Posts
    3

    Re: Convert string to form

    Never mind. I had something typed wrong. That works great. Thanks so much!!!!


  5. #5
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: Convert string to form

    Thanks to Bruno (we will miss him).
    Best regards,
    Cesare Imperiali

    Special thanks to Lothar "the Great" Haensler. Come back soon, you Guru.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

  6. #6
    Join Date
    Sep 2005
    Posts
    1

    Re: Convert string to form

    Dear Cimperiali

    thank u very much, it work properly

    Deepak

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

Featured