473,785 Members | 2,272 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Sub Main Ends so does the application

Admittedly, I am new to VB.NET

I have some real simple code that I am trying to run in VB.NET

Friend Module xxx
Friend F1 As Form1
-----------------

Public Sub Main()

F1 = New Form1

Form1.Show()

End Sub

All I am trying to do is show the form. However, at the End Sub statement
the form closes..... I am confused. Any ideas?
Jul 24 '06 #1
6 1263
if you want to use forms, create a Windows Application, at the end of the
sub, the program terminates, so if you want to use forms (usually) you want
to use a Windows Application
--
-iwdu15
Jul 24 '06 #2
Use Application.Run (Form1) instead of Form1.Show()

Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx
Admittedly, I am new to VB.NET

I have some real simple code that I am trying to run in VB.NET

Friend Module xxx
Friend F1 As Form1
-----------------
Public Sub Main()

F1 = New Form1

Form1.Show()

End Sub

All I am trying to do is show the form. However, at the End Sub
statement the form closes..... I am confused. Any ideas?

Jul 24 '06 #3
Hello Jim,

Actually using the OP's original code fragment it would be Application.Run (F1)..

or, optionally Application.Run (new Form1)
-Boo
Use Application.Run (Form1) instead of Form1.Show()

Jim Wooley
http://devauthority.com/blogs/jwooley/default.aspx
>Admittedly, I am new to VB.NET

I have some real simple code that I am trying to run in VB.NET

Friend Module xxx
Friend F1 As Form1
-----------------
Public Sub Main()
F1 = New Form1

Form1.Show()

End Sub

All I am trying to do is show the form. However, at the End Sub
statement the form closes..... I am confused. Any ideas?

Jul 24 '06 #4
RRowe,

Just as addition,

Did you know that a VBNet mainform has an inbuild submain with an
application run as long as you have not done that yourself.

Cor

"rrowe" <rr***@hotmail. comschreef in bericht
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
Admittedly, I am new to VB.NET

I have some real simple code that I am trying to run in VB.NET

Friend Module xxx
Friend F1 As Form1
-----------------

Public Sub Main()

F1 = New Form1

Form1.Show()

End Sub

All I am trying to do is show the form. However, at the End Sub
statement
the form closes..... I am confused. Any ideas?

Jul 25 '06 #5

Cor Ligthert [MVP] wrote:
RRowe,

Just as addition,

Did you know that a VBNet mainform has an inbuild submain with an
application run as long as you have not done that yourself.

Cor
But if you want to do things like enable visual styles, read a config
file or manually display a splash screen, you will need to make it.
>
"rrowe" <rr***@hotmail. comschreef in bericht
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
Admittedly, I am new to VB.NET

I have some real simple code that I am trying to run in VB.NET

Friend Module xxx
Friend F1 As Form1
-----------------

Public Sub Main()

F1 = New Form1

Form1.Show()

End Sub

All I am trying to do is show the form. However, at the End Sub
statement
the form closes..... I am confused. Any ideas?
Jul 25 '06 #6
But if you want to do things like enable visual styles, read a config
file or manually display a splash screen, you will need to make it.
Or maybe as showed on this page?

http://msdn2.microsoft.com/en-us/library/ms233841.aspx

Cor

<za***@construc tion-imaging.comschr eef in bericht
news:11******** **************@ m73g2000cwd.goo glegroups.com.. .
>
Cor Ligthert [MVP] wrote:
>RRowe,

Just as addition,

Did you know that a VBNet mainform has an inbuild submain with an
application run as long as you have not done that yourself.

Cor

But if you want to do things like enable visual styles, read a config
file or manually display a splash screen, you will need to make it.
>>
"rrowe" <rr***@hotmail. comschreef in bericht
news:%2******* *********@TK2MS FTNGP04.phx.gbl ...
Admittedly, I am new to VB.NET

I have some real simple code that I am trying to run in VB.NET

Friend Module xxx
Friend F1 As Form1
-----------------

Public Sub Main()

F1 = New Form1

Form1.Show()

End Sub

All I am trying to do is show the form. However, at the End Sub
statement
the form closes..... I am confused. Any ideas?

Jul 25 '06 #7

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

Similar topics

45
3627
by: Steven T. Hatton | last post by:
This is a purely *hypothetical* question. That means, it's /pretend/, CP. ;-) If you were forced at gunpoint to put all your code in classes, rather than in namespace scope (obviously classes themselves are an exception to this), and 'bootstrap' your program by instantiating a single application object in main(), would that place any limitations on what you could accomplish with your program? Are there any benefits to doing things that...
75
9907
by: Beni | last post by:
I have been programming in C for about a year now. It sounds silly, but I never took the time to question why a C(or C++ or Java) program execution begins only at the main(). Is it a convention or is there some deeper underlying reason?
2
23725
by: amith shetty | last post by:
Hi, I am new to vb.net and am trying to run a simple program with Sub Main as the start up in a module where i call the code to show a form. when i run , the form is shown and the program ends . how do i prevent this and transfer control to the form and let program running. Thanks in advance
2
1208
by: news.microsoft.com | last post by:
Hi, I have my start point set to the main() sub in a module. In main() I then show my form using the show.dialog method. Problem I am having is that when an error fires anywhere it the app it falls back into the main(), and then goes on with code after the showdialog line, which ends my app.
8
6462
by: koorb | last post by:
I am starting a program from a module with the Sub main procedure and I want it to display two forms for the program's interface, but when I run the program both forms just open and then program closes. Dim FORM1 As New Form1 Dim FORM2 As New form2 Sub main() FORM1.Show() FORM2.Show()
4
1372
by: Ben | last post by:
could someone please suggest to me another way to work around sub main? I am currently migrating 6.0 codes over to .net. as soon as sub main() ran, vb ends the application immediately. So I moved my codes to over to my splash screen form. Made my project preference to run from splash screen as start up. after the splash screen is shown, I ordered it to show my next screen by calling to a new instance of that new screen. However, no...
3
1823
by: John Phelan-Cummings | last post by:
I have a front-end application called, “inbusiness.mdb” and three back-ends databases called, “inbusinessClient_be.mdb”, “inbusinessFund_be.mdb”, and, “inbusiness_be”. I created three back-ends for the potential intensive use of certain areas of the front-end application to their back-end tables by certain type of organizations. With the code below, (used to make future front-end updates
14
1681
by: Sumit77Sen | last post by:
who calls main() ?
2
246
by: ats | last post by:
I have a project I am starting with Sub Main. In my Sub Main I currently have one line of code which is frmMenu.Initialise This event runs through some code that eventually shows the form. However, once the form is loaded teh Sub Main continues on to its end and the project just unloads. What am I missing? TIA --
0
9647
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
9485
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
10356
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, 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...
1
10098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8986
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
5390
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5523
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4058
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
2890
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.