www.webdeveloper.com
Results 1 to 6 of 6

Thread: From manipulation

  1. #1
    Join Date
    Jul 2003
    Posts
    69

    From manipulation

    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

  2. #2
    Join Date
    Nov 2003
    Posts
    655
    Public Class Form1
    ...
    Dim firstForm As Form1

    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.

  3. #3
    Join Date
    Jul 2003
    Posts
    69
    I am new in VB.NET. Could you please provide me piece of code. It would be helpful to understand. Thank you.

  4. #4
    Join Date
    Nov 2003
    Posts
    655
    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?

  5. #5
    Join Date
    Nov 2003
    Posts
    655
    Also, if you're not already aware of it, http://msdn.microsoft.com is an excellent source of information on programming with .NET.

  6. #6
    Join Date
    Nov 2004
    Posts
    4
    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...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles