I just found "ApplicationEvents.vb" which is hidden by default. I
forget how to show it but it is probably easy to find -- I found it so
how hard could it be!
It has several events but no prototypes. That seems a tremendous
oversight!
I am using the one for StartupNextInstance to notify the user that the
program was started twice. The application takes care of exiting (if
you set the single instance check in My Project>Application) but not
notifying the user. If the application is hidden in some way and the
user clicks on the icon/shortcut once again, then just quitting is not
helpful to the user. They will probably click it a few more times and
then logoff or reboot thinking something is drastically wrong. So a
message seems appropriate.
It took a little time to get it right since there are no prototypes.
Here are the events that this namespace handles:
------------------------------------------------
' The following events are available for MyApplication:
'
' Startup: Raised when the application starts, before the startup form
is created.
' Shutdown: Raised after all application forms are closed. This event
is not raised if the application terminates abnormally.
' UnhandledException: Raised if the application encounters an
unhandled exception.
' StartupNextInstance: Raised when launching a single-instance
application and the application is already active.
' NetworkAvailabilityChanged: Raised when the network connection is
connected or disconnected.
------------------------------------------------
That might be too early for you if you want to get input from a text
box, though. That's code after you are running, not during startup.
Here is the code for notifying the user of a multiple invocation:
Private Sub NotAgain(ByVal sender As Object, ByVal e As
Microsoft.VisualBasic.ApplicationServices.StartupN extInstanceEventArgs)
Handles Me.StartupNextInstance
MsgBox("Only one copy of PVM1010 Companion can run on a computer.
Second invocation is exiting.")
End Sub
(note the lines are wrapped due to Usenet length restrictions, not VB
line continuation)
To make this work for startup, remove the characters "NextInstance"
everywhere it appears. I don't know the prototypes for the other calls.
Good luck on that. Intellisense might help you with it but you have to
type it all manually as far as I can tell.
Mike
On Tue, 24 Jun 2008 20:15:15 +0100, in
microsoft.public.dotnet.languages.vb "Rob Blackmore"
<ro*@robblackmore.comwrote:
>It depends on what you want the application to do and what type of
application you are creating (Windows Forms, WPF, Web, etc) - not much help
I know.
Can you give us an idea of the scope of your application and we can offer
more help either on the newsgroup or by emailing me directly.
It is also worth picking up a VB.Net book or two to help you get started.
Kind regards
Rob
"Jeff Ciaccio" <no****@noreply.orgwrote in message
news:1C**********************************@microso ft.com...
>I'm new to vb.net and was wondering what the syntax is for application
events such as starting up or shutting down. For example, if you would
just like to get a user's name with an input box when they open the app or
a form.
Thanks
--
Jeff Ciaccio
Physics and AP Physics Teacher
Sprayberry High School; Marietta, GA
Blog: http://sprayberry.typepad.com/ciaccio