The goal is to opening a new form by clicking a button in the old form and at the same time the old form will be closed. How to do that?
Following code is giving me error.
Code:
Public Class Form1
Inherits System.Windows.Forms.Form
Dim secondForm As Form2
Dim firstForm As Form1
#Region
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
secondForm.Show()
firstForm.Close()
End Sub
End Class
You're trying to declare an object of the class within the definition of the class itself.
Also, secondForm would belong to firstForm, so, IIRC, if you close firstForm, you'd also lose secondForm.
Way out: In the module, form, or class that creates the instances of Form1 and Form2, put in an event handler for the button click on the Form1 instance and deal with the showing and hiding/closing there.
I havn't done any non-web programming lately, longer still since doing a non-web Windows GUI app, so I don't really have any good examples or recollections at hand.
Just to confirm, you are aware that the code you are working with ISN'T for web pages, but rather for Windows GUI apps?
i recommend u to buy or download a softcopy of a book focusing on object oriented design and object oriented programming , it'd be better for u if the book uses VB.net for its example codes...
Bookmarks