I have an application that starts with a Module (Sub Main) that calls a few forms in order. When I close the next to last form, the last form is called and closes immediately. I have application.run (me) in the load event for that form and it opens fine if I call it at the beginning of the module. Here is the module code....
Module mdlLogon
Sub main()
Dim OpenFrmDbConnec t As New FrmDBConnect()
OpenFrmDbConnec t.Show()
If Form1.ds = Nothing Then
Dim Result As DialogResult
Result = MessageBox.Show ("You must setup the database connections, Click Ok to do so or Cancel to quit the program.", "Initial Setup",
MessageBoxButto ns.OKCancel, _MessageBoxIcon .Exclamation, MessageBoxDefau ltButton.Button 1, MessageBoxOptio ns.ServiceNotif ication)
If Result = DialogResult.OK Then
Dim OpenFrmSetup As New FrmSetup()
OpenFrmSetup.Sh ow()
ElseIf Result = DialogResult.Ca ncel Then
Exit Sub
End If
End If
Dim OpenFrmLogon As New FrmLogon()
OpenFrmLogon.Sh ow()
' This is the call that dies below..
Dim OpenForm1 As New Form1()
OpenForm1.Show( )
End Sub
End Module
This is driving me crazy!! Please someone help!!!! 13 1138
"Shawn" <sh**********@c cci.org> schrieb: I have an application that starts with a Module (Sub Main) that calls a few forms in order. When I close the next to last form, the last form is called and closes immediately.
\\\
Public Module Program
Public Sub Main()
Dim f As New Form1()
f.Show()
Application.Run ()
End Sub
End Module
///
In the project properties, select 'Sub Main' as startup object. Place the
code below in a button's 'Click' event handler:
\\\
Dim f2 As New Form2()
f2.Show()
Me.Close()
///
You can exit the application by calling 'Application.Ex itThread'. Take a
look at the 'ApplicationCon text' class too.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
This pretty much looks like what I already have... Am I missing something?
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message
news:O%******** ********@TK2MSF TNGP09.phx.gbl. .. "Shawn" <sh**********@c cci.org> schrieb:I have an application that starts with a Module (Sub Main) that calls a
fewforms in order. When I close the next to last form, the last form is
calledand closes immediately.
\\\ Public Module Program Public Sub Main() Dim f As New Form1() f.Show() Application.Run () End Sub End Module ///
In the project properties, select 'Sub Main' as startup object. Place the code below in a button's 'Click' event handler:
\\\ Dim f2 As New Form2() f2.Show() Me.Close() ///
You can exit the application by calling 'Application.Ex itThread'. Take a look at the 'ApplicationCon text' class too.
-- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
"Shawn" <sh**********@c cci.org> schrieb: This pretty much looks like what I already have... Am I missing something?
Maybe the reason that your code doesn't work is that you are calling
'Application.Ru n' in the form's 'Load' event handler -- which will already
require a message pump.
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Yes.
As Herfried indicated, you should have the Application.Run in the Sub Main,
not in the Load event handler of a form.
It might seem that the difference is 'being picky', but the difference is
VERY important.
"Shawn" <sh**********@c cci.org> wrote in message
news:%2******** ********@TK2MSF TNGP12.phx.gbl. .. This pretty much looks like what I already have... Am I missing something?
"Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message news:O%******** ********@TK2MSF TNGP09.phx.gbl. .. "Shawn" <sh**********@c cci.org> schrieb: >I have an application that starts with a Module (Sub Main) that calls a few >forms in order. When I close the next to last form, the last form is called >and closes immediately.
\\\ Public Module Program Public Sub Main() Dim f As New Form1() f.Show() Application.Run () End Sub End Module ///
In the project properties, select 'Sub Main' as startup object. Place the code below in a button's 'Click' event handler:
\\\ Dim f2 As New Form2() f2.Show() Me.Close() ///
You can exit the application by calling 'Application.Ex itThread'. Take a look at the 'ApplicationCon text' class too.
-- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
Well, I made the changes and it still works that same. I like having the
application.run code in the module, so thanks, but it still does not keep
Form1 open. I even tried creating a new blank form just to see if there was
some code in form1 I was not seeing, but the same thing happens.
Also, if I replace the call to form1 with a second call to FrmLogon, it
calls it twice, but nothing else seems to start in that last position...
"Stephany Young" <noone@localhos t> wrote in message
news:ew******** ******@TK2MSFTN GP14.phx.gbl... Yes.
As Herfried indicated, you should have the Application.Run in the Sub
Main, not in the Load event handler of a form.
It might seem that the difference is 'being picky', but the difference is VERY important.
"Shawn" <sh**********@c cci.org> wrote in message news:%2******** ********@TK2MSF TNGP12.phx.gbl. .. This pretty much looks like what I already have... Am I missing
something? "Herfried K. Wagner [MVP]" <hi************ ***@gmx.at> wrote in message news:O%******** ********@TK2MSF TNGP09.phx.gbl. .. "Shawn" <sh**********@c cci.org> schrieb: >I have an application that starts with a Module (Sub Main) that calls
a few >forms in order. When I close the next to last form, the last form is called >and closes immediately.
\\\ Public Module Program Public Sub Main() Dim f As New Form1() f.Show() Application.Run () End Sub End Module ///
In the project properties, select 'Sub Main' as startup object. Place the code below in a button's 'Click' event handler:
\\\ Dim f2 As New Form2() f2.Show() Me.Close() ///
You can exit the application by calling 'Application.Ex itThread'. Take
a look at the 'ApplicationCon text' class too.
-- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://classicvb.org/petition/>
Shawn,
I never use an application start or a sub main in VBNet form program
A login form is typical a modal form in the load event of a main form. When
you do this in pseudo than
dim frm as New myloginform
(Here you can use the dialogOK if, i don't do it now)
frm.showdialog
if frm.pw not is correct then
me.close 'or whatever
end if
frm.dispose
When the password is not correct than will the login form the only one that
was showed, because the form is showed after the formload.
I hope this helps,
Cor
Cor,
"Cor Ligthert" <no************ @planet.nl> schrieb: A login form is typical a modal form in the load event of a main form. When you do this in pseudo than
dim frm as New myloginform (Here you can use the dialogOK if, i don't do it now) frm.showdialog if frm.pw not is correct then me.close 'or whatever end if frm.dispose
When the password is not correct than will the login form the only one that was showed, because the form is showed after the formload.
Mhm... Why should the main form be loaded if there is no guarantee that it
will be shown at all? If the login form is shown, why is it shown modally
if there are no other forms open?
--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>
Herfried Mhm... Why should the main form be loaded if there is no guarantee that it will be shown at all? If the login form is shown, why is it shown modally if there are no other forms open?
Probably it is not even loaded.
This are the first instructions.
However why not?
And even when it takes time, when it is an unauthorised action than it will
even stop the ones when it takes time.
(And authorised it cost nothing more).
However why not?
Cor
Well, I have the Sub Main Module doing a few different things. The program
will support online and offline modes so that different forms will be
started if the database can not be contacted. So, during the module startup,
I run a form that displays a staus bar and that form opens a new thread that
tests the ability to connect to the database. It then sets a variable that
tells the program which mode it is in.
What really has me confused is the fact that I can call the login box form
several times at the end of the module and it will stay open each time, but
anything else will close.
I thought about starting the Form1 and setting the opacity to 0 while the
login for runs, but it is a bit sloppy to me.
"Cor Ligthert" <no************ @planet.nl> wrote in message
news:uq******** ******@TK2MSFTN GP15.phx.gbl... Herfried Mhm... Why should the main form be loaded if there is no guarantee that it will be shown at all? If the login form is shown, why is it shown modally if there are no other forms open?
Probably it is not even loaded. This are the first instructions.
However why not?
And even when it takes time, when it is an unauthorised action than it
will even stop the ones when it takes time.
(And authorised it cost nothing more).
However why not?
Cor
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Eric Cadwell |
last post by:
We're running Load Runner to test a large 1.0 based WinForms application.
I'm getting the following exception when opening and closing a form 400 -
450 times. The form contains several controls and custom UserControls. All
the code is native C#.
I'm not making an explicit call to ToBitmap or DrawIcon in my code. Can
anyone help?
Exception Caught in Main(): at System.Drawing.Graphics.GetHdc()
|
by: Jelmer |
last post by:
Hi I've been trying to create an addin similar to Find & Replace from Rick
Fisher that looks thru your tables / queries / forms / modules etc.. for a
reference to a string and optionally let's you replace it.
In order to get this to work I need to get
- the tablenames and columnnames
- the queries in plaintext
- the properties of a form and the properties of elements contained within
it
|
by: BLUE WATER |
last post by:
Help,
When I am finished entering in data into my form A, I press the save button
that
saves this new data to a new record. However I would like my other form to
open at a specific record, the record that I just finished working on.
Ideas?
|
by: Mike Wilson |
last post by:
Is there a way to open an OLE DB database from within Access?
I would like to use the Access GUI with its table and query
explorer to examine a database only available through an OLEDB
provider interface.
I have seen several references on how to open an OLE DB
database through VBA/ADO code but I wouldn't know how to go
from there to actually have the database available in the
Access GUI...
|
by: MartinR |
last post by:
Hi,
I'm still new to writing code in vba as I've only been introduced to
access three weeks ago. I have written this code below and it executes
but does not do what I want it to do. What I want is the form
"Sparesform" to open when I double click on the "index" field for the
record I wish to view. The index field is part of a subform. What is
happening at the moment is the form "Sparesform" is opening but does
not go to the correct record...
| |
by: robertmeyer1 |
last post by:
Hey,
I am having a problem with opening some forms. I have several forms. The forms are based off the same table, tblClient. Each form has a sbf inserted into it. These sbf’s are each based off its own query. These queries are all based off the same table tblAnswers. The queries limit the questions for each form. So for example form 1 has questions 101-125; form 2 has questions 126-150. tblAnswers is created from an append query,...
|
by: Tony K |
last post by:
I have a MDI application. On the menu toolstrip child forms are selected
from one of the menus. I don't want to play the disable/enable menu item
game. I have selected that open forms are added to the "Window" menu item.
What I'm looking for is when the user clicks on the menu item to open the
form, how can I check to see if it's open already and if so then set the
focus (if possible).
What happens now is if the menu item is clicked...
|
by: Mucker |
last post by:
This could be a difficult one, so please bear with me.
I've an assembly containing Delphi 2006.NET forms.
A C# app, via reflection opens these forms . This works fine - I've a C#
app, opening Delphi 2006.NET forms.
Some of these forms are MDI Child forms. Exceptions are thrown - "Cannot
create form - No MDI Forms are currently active" when the C# app tries
to open one of these.
|
by: John |
last post by:
Hi
I have a number of forms which open like this;
Dim frm1 As frmForm1 = New frmForm1
Dim frm2 As frmForm2 = New frmForm2
Dim frm3 As frmForm3 = New frmForm3
Dim frm4 As frmForm4 = New frmForm4
.....
|
by: =?Utf-8?B?RXRoYW4gU3RyYXVzcw==?= |
last post by:
I am (still) relatively new to Windows applications, most of my experience
has been Web based, and I am confused about what exactly happens when the
Main() method is called and how to manipulate forms opening & closing.
An example of this issue is as follows. I have a logon form open as the
first thing. The main functional form opens when a user has successfully
logged on. From the main form, a user should be able to logout which will...
|
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,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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...
|
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...
|
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...
|
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
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
|
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...
| |