473,320 Members | 1,978 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,320 software developers and data experts.

Sub main & application run

Using VS 2003, VB.Net, MSDE...

The example below from help shows that the Sub Main contains an explicit
Application.Run. Is this required? Are there pros and cons of doing it
this way? I have not been using application.run on my Main_Thread (i.e. sub
main) and it seems to be Ok.

Under what condistions should you explicityly put an application.run in a
sub main (ie Main_Thread)?

Please advise.

Shared Sub Main()
' Starts the application.
Application.Run(New Form1())
End Sub

Thanks!

Bob Day
Nov 20 '05 #1
4 1444
Bob,

* "Bob Day" <Bo****@TouchTalk.net> scripsit:
Using VS 2003, VB.Net, MSDE...

The example below from help shows that the Sub Main contains an explicit
Application.Run. Is this required? Are there pros and cons of doing it
this way? I have not been using application.run on my Main_Thread (i.e. sub
main) and it seems to be Ok.


What would you use instead? Yes, 'Application.Run' is the preferred
method to start a message loop.

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #2
In article <uI**************@TK2MSFTNGP10.phx.gbl>, Bob Day wrote:
Using VS 2003, VB.Net, MSDE...

The example below from help shows that the Sub Main contains an explicit
Application.Run. Is this required? Are there pros and cons of doing it
this way? I have not been using application.run on my Main_Thread (i.e. sub
main) and it seems to be Ok.

Under what condistions should you explicityly put an application.run in a
sub main (ie Main_Thread)?

Please advise.

Shared Sub Main()
' Starts the application.
Application.Run(New Form1())
End Sub

Thanks!


If your starting a windows forms app from a sub main, then yes it is
required. Otherwise, your main form will appear and then close when the
main method exits. The application.Run method creates the message loop
for your main form, and also sets that form as the application context
- so when it closes the rest of the app closes. If you are using a form
as your startup object, VB just generates this code behind your back....

It is also possible to use the ShowDialog method of your main form from
the Sub Main - but that isn't really the recommended method.
--
Tom Shelton [MVP]
OS Name: Microsoft Windows XP Professional
OS Version: 5.1.2600 Service Pack 1 Build 2600
System Up Time: 0 Days, 0 Hours, 8 Minutes, 49 Seconds
Nov 20 '05 #3
Hi Bob,

Thanks for posting in the community.

Did you have any concern on this issue?
If so please post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #4
Thanks, the issue is resolved.

Bob Day
"Peter Huang" <v-******@online.microsoft.com> wrote in message
news:qW****************@cpmsftngxa07.phx.gbl...
Hi Bob,

Thanks for posting in the community.

Did you have any concern on this issue?
If so please post here.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Nov 20 '05 #5

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

Similar topics

192
by: Kwan Ting | last post by:
The_Sage, I see you've gotten yourself a twin asking for program in comp.lang.c++ . http://groups.google.co.uk/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&th=45cd1b289c71c33c&rnum=1 If you the oh so mighty...
4
by: MLH | last post by:
A programmer developed an AMP (Apache/MySQL/PHP) application for me. When he was done, he sent me the PHP files and the MySQL dump file. Now, when I connect to the application on my LAN using...
4
by: johkar | last post by:
When the output method is set to xml, even though I have CDATA around my JavaScript, the operaters of && and < are converted to XML character entities which causes errors in my JavaScript. I know...
1
by: Nathan Alden | last post by:
I have an XSD defined as the following: <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"...
0
by: SeanGallavan | last post by:
Our Environment: Two network load balanced (using Microsoft NLB software) webservers with session maintained in a SQL Server database. NLB is configured with no affinity settings and two...
7
by: =?Utf-8?B?Vmlu?= | last post by:
Hi, I have a question. I created a simple executable program using Visual C++ from Visual Studio 6.0 This program is called from a script that passes in one argument. Now, my question is: ...
0
by: Mudiya Dissa | last post by:
Hi, I have some code on my application like the following <% redirectUrl = "mypage.asp?type=100&id=something&view=10 'some more asp code
8
by: gtb | last post by:
The lines if __name__ == 'main': someClass().fn() appear at the end of many examples I see. Is this to cause a .class file to be generated? The last line of the sample below has a string...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.