CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: Help a Beginner

  1. #1
    Join Date
    May 2001
    Posts
    1

    Help a Beginner

    How do I load Forms?? I just started to learn VB today and I cant seem to figure out how to change to another form when I click a particular Command? Probably everyone in this forum knows how to do that...please let me know


  2. #2
    Join Date
    Feb 2001
    Location
    Stamford CT USA
    Posts
    2,167

    Re: Help a Beginner

    Example:

    Form1: consists of Command1 (command button)

    private Sub Command1_Click()
    ' load form2
    Load Form2
    Form2.Show
    End Sub




    Form2: consists of Command2

    private Sub Command2_Click()
    ' close form
    UnLoad Form2
    End Sub




    -Cool Bizs

    Good Luck,
    -Cool Bizs

  3. #3
    Join Date
    May 2001
    Posts
    5

    Re: Help a Beginner

    you can actually skip the load form2 and just use:
    form2.show, the load will be automatic


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

    Re: Help a Beginner

    ...moreover (read others reply, first!) you can do a "strange" thing via VB:
    you can declare a variable as form1 and then use the variable... ie:
    have a form1 and form2 in your project.
    in form1, at top declare:
    dim frmF2 as Form
    on command1 click, write:
    set frmF2= new Form2
    frmF2.show 'this will put a new istance of form2 each time you click on command1 in form1. Click 3 times and move form2 around and see...!

    'do not forget this code in Form1 unload event:
    Dim f As Form
    For Each f In Forms
    If f.Name <> "Form1" Then
    Unload f 'unload loaded forms if any
    Set f = Nothing
    End If
    Next f
    If Not frmF2 Is Nothing Then
    Set frmF2 = Nothing
    End If
    End Sub

    'Amazing, isn't it?
    :-)
    Best regrads,
    Cesare Imperiali

    Special thanks to Lothar "the Great" Haensler, Tom Archer, Chris Eastwood Bruno Paris and all the other wonderful people who made and make Codeguru a great place. Come back soon, you Gurus.
    ...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.

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