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

Thread: next form

  1. #1
    Join Date
    Oct 2005
    Posts
    2

    next form

    hey..
    i would like to know how would i be able to add a button to a form and wen its clicked go to another form..


    thanks..

  2. #2
    Join Date
    Feb 2005
    Location
    Israel
    Posts
    1,475

    Re: next form

    Add the button, and double click on it. You will generate the Click event handler. Inside the method write:
    Code:
    Dim nextForm as New Form2
    nextForm.Top = Me.Top
    nextForm.Left = Me.Left
    nextForm.Width = Me.Width
    nextForm.Height = Me.Height
    Me.Visible = False
    nextForm.Show()

  3. #3
    Join Date
    Oct 2005
    Posts
    2

    Re: next form

    thanks alot that worked. But i got a question. When i get this "Sub Main was not found", how can i avoid this when creating more then 1 form.

  4. #4
    Join Date
    Feb 2005
    Location
    Israel
    Posts
    1,475

    Re: next form

    Either set the properties Startup object, or create a Sub Main
    To set the startup object, right-click on the project in Solution Explorer, and you will see in General option the Startup Object field. You will see all the forms in the project and Sub Main. Just select one of the forms.

    To create a Sub Main (you only need to do this if showing the form is not the only thing you need to do on application startup like reading user command line arguments):
    Add this sub to one of your classes:
    Code:
    Public Shared Sub Main()
    	Application.Run(New Form1());
    End Sub
    You can run one form, and you can also read arguments (look at MSDN)

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