Loading and closing form in VB 2005

I have two form in my application form1 and form2. Here, i want to show the form2 from form1 by using a button. And i want to reverse back to my form1 from form2 using same technique. But i want to close form1 (Not visible=false or hide) after loading form2 and same thing in reverse back also.

I have tried like this....

'for from1
form2.show()
'form1.close ' not accepted
me.close

In my above code whole application is closing.

'for form2
form1.show()
me.close()

Here it is working in form2

I want to know that can we close our current form after showing another form? Please guide me.

Because VB.NET version 2005 and later version uses "Default Form Instance". (here is good discussion) It means the name of Form (or you can say class name) represents an instance (object reference) and of course the form inside you are working is also an instance of same form. In short you can't use or access the members of current form using "Default Form Instance" name, use Me instead.

Thanks for replying sir, i understand that i can't access the members of current form using "Default Form Instance" name. My question is that can't we close the form1 after showing the form2? And when i use me.close in form1 (as i have mentioned earlier) the whole program is closing.

Thanks for replying sir, Hiding and making visible = False, i can do that as i have mentioned in my thread also. May be it is not possible for closing form1 after loading/showing form2. Because it is possible in VB 6.0. I just want to know that things.

I apologize I don't know how I missed that.
What I did was set a form up to be my projects main form but the form is never used and is always hidden.
Instead of showing the main form on load I showed form1.
When doing this you can close and load forms as you please without having the application close, as long as you don't touch the main form(the hidden one). And when you want to exit your application you just use.

Application.Exit()

There is probably a better way to do this, but not one that I know of.

Hiding my form1 (first form) and as you told, hiding first form completely for closing and showing other form is more or less same. Actually, i want to free the complete memory which is taking by form1. Anyway, thanks for your suggestion sir.

Dear Vanzhyme,

Thanks for replying sir, but sorry, right now I don't want to use IsMDIContainer. Any other suggestion sir?

I have two form in my application form1 and form2. Here, i want to show the form2 from form1 by using a button. And i want to reverse back to my form1 from form2 using same technique. But i want to close form1 (Not visible=false or hide) after loading form2 and same thing in reverse back also.

I have tried like this....

'for from1
form2.show()
'form1.close ' not accepted
me.close

In my above code whole application is closing.

'for form2
form1.show()
me.close()

Here it is working in form2

I want to know that can we close our current form after showing another form? Please guide me.

I apologize I don't know how I missed that.
What I did was set a form up to be my projects main form but the form is never used and is always hidden.
Instead of showing the main form on load I showed form1.
When doing this you can close and load forms as you please without having the application close, as long as you don't touch the main form(the hidden one). And when you want to exit your application you just use.

Application.Exit()

There is probably a better way to do this, but not one that I know of.

You have said, "set a form up to be my projects main form but the form is never used and is always hidden." But what if at some point there is bug and it closes all of the visible forms but not call Application.Exit(). The app will be running forever, isn't it?

You have to change the propierties of your Project in order to make the program closing until ALL FROMS are closed. You will be able to Open Form2 (before) and Close Form1 (After) with out the program get closed.

In the Editor Menu: Project -> Properties of [Project Name]
Project Properties will apear on a new tablet
In "Application" look for something like: "Turn Off Mode" and select something like "When closing last form"

Hi. so this is actually a continuation from another question of mine[Here](https://www.daniweb.com/programming/software-development/threads/506795/dynamically-add-values-into-datagridview-cell-from-listbox-vb2010) but i was advised to start a new thread as the original question …

I have a 2d matrix with dimension (3, n) called A, I want to calculate the normalization and cross product of two arrays (b,z) (see the code please) for each column (for the first column, then the second one and so on).
the function that I created to find the ...

Write a C program that should create a 10 element array of random integers (0 to 9). The program should total all of the numbers in the odd positions of the array and compare them with the total of the numbers in the even positions of the array and indicate ...