473,411 Members | 2,059 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Disposing of a log in window

Hi !

I am trying to dispose of the startup form in my application a login
form (frmLogin) after it calls the main form (frmMain). I cant seem to
get it to work. Here is my code.

frmLogin Code
==============

Sub btnSave_Click

Dim mainF As New frmMain

mainF.Show()
Me.Dispose()

End Sub

The main form flashes up and then the whole app closes down as it goes
to the next line (Me.Dispose()). What needs to happen is the main form
loads then the login form is not visible and unloaded from memory.

Any help is appreciated, thanks !
Nov 20 '05 #1
2 954
Hi,

Use mainF.ShowDialog instead of mainF.Show. Showdialog will
wait until the form is closed before executing the next line of code.

Ken
-----------------
"Damian" <da*****@webaware.com.au> wrote in message
news:86**************************@posting.google.c om...
Hi !

I am trying to dispose of the startup form in my application a login
form (frmLogin) after it calls the main form (frmMain). I cant seem to
get it to work. Here is my code.

frmLogin Code
==============

Sub btnSave_Click

Dim mainF As New frmMain

mainF.Show()
Me.Dispose()

End Sub

The main form flashes up and then the whole app closes down as it goes
to the next line (Me.Dispose()). What needs to happen is the main form
loads then the login form is not visible and unloaded from memory.

Any help is appreciated, thanks !

Nov 20 '05 #2
Cor
Hi Damian,

I had this problem yesterday also when I was making a sample from a splash
form.
Today I thought let find somebody else find this solution for you, but
thinking it over it is simple.

I hope this helps?

Cor

\\\
private frm as new form2
Private WithEvents timer1 As New Windows.Forms.Timer
Private Sub Form1_Load(ByVal sender _
As Object, ByVal e As System.EventArgs) _
Handles MyBase.Load
timer1.Enabled = True
timer1.Interval = 12500
frm.Show()
End Sub
Private Sub Timer1_Tick(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles timer1.Tick
if frm.readyswitch = true then 'readyswitch as public variable
frm.Close()
frm.Dispose()
timer1.Enabled = False
end if
End Sub
///
Nov 20 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Carl Mercier | last post by:
Hi, I'm trying to close and dispose a form that is running in another process, but I get the error message "A first chance exception of type 'System.ObjectDisposedException' occurred in...
15
by: Chris Capel | last post by:
I've heard a lot of talk on the forum about memory managment in .NET and disposing things, finalizing them, garbage collection, etc. My question is which managed types need to be disposed after...
10
by: Patrick De Ridder | last post by:
I have been looking at an example, and there is something I don't inderstand. Given: form1 calls form2 --------- Question: What is the use of having these lines in form2 --------------...
4
by: Dakkar | last post by:
I have a program with windows forms and after execution of my program im making it invisible for working background progress and i have a dispose function like this protected override void...
13
by: MuZZy | last post by:
Hi, Just wanted to make sure i get it right: consider this class: // =========== START CODE ============= class Test { private SqlConnection con = null; public void Connect() { con = new...
5
by: Chris | last post by:
I have a form that requires drawing custom lines on it. The color of the lines is suppose to be the same as the forcolor of the form. Am I doing this the most efficent and correct way? ...
0
by: Gman | last post by:
Hi, Objective: Draw a grid on a bitmap and set this as a panel's image. (Rather than draw the grid directly on the panel and redraw repeatedly in the paint event.) Problem: It works fine....
8
by: Varangian | last post by:
Hello, was wondering of how to dispose of managed resources? or referencing every member of a class to null will release resources...? http://www.marcclifton.com/tabid/79/Default.aspx...
4
by: Peter Webb | last post by:
I am supposed to manually dispose of some instances, such as Brushes, right? I have a couple of questions: 1. I have the following code, and it works just fine: ...
29
by: Jerry Spence1 | last post by:
I'm rather confused as to whether something should be disposed of, or not. What is the general rule? How can you be sure of doing the right thing? I've heard about disposing unmanaged resources but...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.