Forms

I have no idea how create a button and tell the button to pull up another form. What is the command. Thanks!
steverpayneAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
carmodykConnect With a Mentor Commented:
Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click
 Dim objForm As frmNewForm
        objForm = New frmNewForm
        objForm.Owner = Me
        objForm.ShowDialog()
        objForm.Dispose()
  End Sub

What this will do is create a new instance of the form you want to open, and it will keep the form open all to itself, until the user closes it.  Try it out, see if you like it.
0
 
carmodykCommented:
Dim objForm As frmNewForm
        objForm = New frmNewForm
        objForm.Owner = Me
        objForm.ShowDialog()
        objForm.Dispose()
0
 
steverpayneAuthor Commented:
is this in visual basic .net express 2005?
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
carmodykCommented:
Sorry, let me be more specific:  Place a button on your form from the toolbox.  Double click the button, which will take you to the code for the button.  Place the following code in your subroutine for the button and it should look like this:

Private Sub Yourbutton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles YourButton.Click
      Dim objForm As frmNewForm
        objForm = New frmNewForm
        objForm.Owner = Me
        objForm.ShowDialog()
        objForm.Dispose()
End Sub
0
 
carmodykCommented:
I did code this in VB.NET 2003, but I don't think it should matter.  If it does, let me know.
0
 
gangwischCommented:
sub button1_click
dim a as new form2
a.show
me.hide 'optional
end sub
0
 
Mike TomlinsonMiddle School Assistant TeacherCommented:
In VB.Net 2005, you can use the "default instance" of forms just like you did in VB6.  This is useful for when you only want ONE instance of each form available.

Instead of creating a new instance as shown above, you simply use the forms name:

    Private Sub Button1_Click(...) Handles Button1.Click
        SomeForm.Show()
    End Sub

You can use "SomeForm" from anywhere in the application to refer to the default instance.

If you want more than one instance of "SomeForm" then do as above and create new instances with the "new" keyword.
0
 
steverpayneAuthor Commented:
this is what the button looks like. Now where do i insert that i want it to open or close the form?


 Private Sub Button8_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button8.Click

    End Sub
End Class
0
 
steverpayneAuthor Commented:
thank you it was very simple at the code that you provided. Since I am new and taking a class, i am new at this. Thanks!
0
All Courses

From novice to tech pro — start learning today.