473,769 Members | 5,834 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Close the opened form

Hi,

I have a button (Button1) to open the main form. If I want to have another
button to close this opened form, how do I do it without making Mainform a
global variable?

Thanks!

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click

Dim MainFrom As New frmMain

MainFrom.Show()

End Sub

Private Sub Button2_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button2.Click

' Close the form opened by Button1

End Sub
Nov 21 '05 #1
1 1207
"anthony" <an*******@cont rolengineer.com > schrieb:
I have a button (Button1) to open the main form. If I want to have
another
button to close this opened form, how do I do it without making Mainform a
global variable?


\\\
Private m_MainForm As MainForm
..
..
..

' In the open button's 'Click' event handler...
If m_MainForm IsNothing OrElse m_MainForm.IsDi sposed Then
m_MainForm = New MainForm()
m_MainForm.Show ()
End If
..
..
..

' In the close button's 'Click' event handler...
If Not m_MainForm Is Nothing AndAlso Not m_MainForm.IsDi sposed Then
m_MainForm.Clos e()
End If
///

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Nov 21 '05 #2

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

Similar topics

1
824
by: Obscurr | last post by:
hi, I'm wondering how I can close a window that is not active at the moment using javascript? example : I have two Internet Explorer windows opened, and I want to close the one I'm not currently using. Maybe some form of window.close()? obscurr
6
2744
by: marcelf3 | last post by:
Hello.. This page opens a window with some information, but everytime the user changes a field in the parent window, the child window needs to be closed. These 2 functions were supposed to do the work. Nota() - opens new window. fechaNota() - closes the window opened by Nota() here is the code.
6
12819
by: Sujan | last post by:
Hello all, Help me! -------------------- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <script language="JavaScript"> <!--
2
5024
by: Bruno Rodrigues | last post by:
Hey, it's me again. Is there a way to, when closing a form, close also all forms opened inside this one? I'm not talking about MDI. Let's say I create and open three forms in Form1. When I close Form1, and he's not the main form of my app, I want to close all the three forms I opened. It would be nice to do that without a Form collection so I don't need to iterate throut it. Thanks.
7
3046
by: Paul | last post by:
Hi I have a web application that has a log off selection, just redirects the browser to a form with a label displaying you are loging off. In part of the application I open a new window and was wondering if there is a way to close all windows associated with the web application when the user selects the log off selection? Thanks. -- Paul G Software engineer.
3
18217
by: Todd Jaspers | last post by:
Hey guys, I've developed a C# Web Form using Visual Studio 2005. I can't quite figure out how to exit the form though??? On my form, I have a button which says "CLOSE". I'd like for someone to be able to click that, and then have it automatically just exit out of the application. How do I do that? This is my on event procedure, what should be in here??? protected void btnClose_Click(object sender, EventArgs e)
2
2951
by: jpr | last post by:
I am using moduled to open forms. I run them from a menu that I have created on the toolbar. The source of the forms are queries all with record source to "lstpreinterview" on a form named eforms. Public Function Openmyform() If IsNull(Forms!eforms!lstPreInterview) Then MsgBox "Sorry. You need to select a record!" Exit Function Else
3
3012
by: godhulirbalaka | last post by:
Dear Sir/Madam, I am new vb 6.0 user. I am developing Shop Management Program. I have a main form with buttons and menus. when i click any button then respective form is open. I want to set a command by which when i click a button then respective form will open and when i click another button then previous opened form will close and new form will open. that means at a time only one form will active with the main form. Please note that i dont...
6
3246
by: =?Utf-8?B?UGF1bA==?= | last post by:
I am looking for a java script to close a web form that I can attatch to a button click event. I am using vs2005, c#. Thanks -- Paul G Software engineer.
0
9579
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9416
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10032
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9849
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8861
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6661
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5433
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3948
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2810
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.