Results 1 to 9 of 9

Thread: Newbie Q: What is the code to start new form?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Posts
    100
    I have just started VB programming.

    I have a form at the start and some text boxes on it.
    I have a command button at the bottom and when I press the command button i want it to load another particular form.

    it is like making a command button linked to msgbox but i dont want msgbox. I want another sub form.

    Thanks all!!

  2. #2
    Addicted Member
    Join Date
    Sep 2000
    Posts
    138
    Is this what you are asking for?

    Code:
    --------------------------
    'Make a CommandButton called cmdButton on the first form and copy this code onto the form.

    'Make another form at design time, with the name frmAnother.frm

    'Run the project and click cmdButton and the other form shows.

    Private Sub cmdButton_Click()

    Load frmAnother
    frmAnother.Show

    End Sub

  3. #3
    Frenzied Member
    Join Date
    Aug 2000
    Location
    Birmingham, AL
    Posts
    1,276
    That is right, but you do not need "Load Form2".
    Show is enough.
    Code:
    Private Sub Command1_Click()
    
        Form2.Show
        
    End Sub

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Posts
    100

    Cool

    Thank you for the help
    I didn't expect help to arrive so shortly
    thank you!!

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Posts
    100

    Exclamation

    How do i make it that when i load the second form the first form will disappear??

  6. #6
    Addicted Member c@lle's Avatar
    Join Date
    Oct 1999
    Location
    Belgium
    Posts
    179
    to hide the first window:
    Code:
    frmOne.hide

  7. #7
    Fanatic Member
    Join Date
    Sep 1999
    Location
    Bethel, North Carolina, USA
    Posts
    987
    Code:
    Private Sub Command1_Click()
        Load Form2
        Form2.Show
    
        Form1.Hide
        Unload Form1
    
    End Sub
    {Insert random techno-babble here}

    {Insert quote from some long gone mofo here}

  8. #8
    Fanatic Member
    Join Date
    Feb 2000
    Location
    The Netherlands
    Posts
    715
    You can also use
    Code:
    FrmTwo.Show 1
    This way, the 2nd form is modal. So, you can't switch back to the 1st form, until FrmTwo.Hide.
    (Like a normal Messagebox)
    Oetje
    [email protected]
    93606776
    Visual Basic 6, Windows 2000

    Never pet a burning dog

  9. #9

    Thread Starter
    Lively Member
    Join Date
    Nov 2000
    Posts
    100

    Wink

    Thanks
    gotcha

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