Daily Newbie - 05/01/2001
“To Start Things
Love it, hate it, or just don't care, the Daily Newbie is back. I have decided to change the format a little. Although
the layout is going to be the same as it always was, I am going to start using the PSC Ask A Pro discussion forum
to choose my topics. I find that newbies make up a large part of that forum and they ask some pretty good questions.
Also, if you have a question, email me and I will try to work it in.
The App Object
Retriving information about your application at runtime.
VB Help Description: It determines or specifies information
about the application's title, version information, the path and name of its executable file and Help files,
and whether or not a previous instance of the application is running.
English: Returns information about the running application.
Usage: MsgBox "This application is named: " & App.Title
Note: This article shows the most common and useful properties for the App object. There are a total of 30
properties that you can access from code.
Comments - The comments that were added in the Make tab of the project before compiling.
Company Name = The company name that was added in the Make tab before compiling. This is useful for copyright
protection when creating reusable objects (.dll's or .ocx's)
ActiveX .dll's or
EXEName - The name of the executable file that is running.
FileDescription - Again, entered in the Make tab before compiling. A general description of a project.
HelpFile - The Windows help file associated with this application. This property could be used to make sure
the help file exists before trying to open it.
Major - The Major application version. In MyApp Version 2.5.34, the Major Version would be "2".
Minor - The Minor application version. In MyApp Version 2.5.34, the Minor Version would be "5".
Revision - The Revision (or "Build") number of they application version. In MyApp Version 2.2.34, the Revision would be "34"
Path - Probably the most commonly used property. Returns the full path to the folder that the executable was
Title - The name of the application (i.e. MyCoolApp or whatever you compiled it as). This is not necessarily the same as the
EXEName, since EXE's can be renamed at will.
StartLogging - Sets the execution log path to a log file. Can also be set to log to the NT Event Log.
LogEvent - Causes a log event to be written to the
log path that was specified in the StartLogging method.
To find out what path the .exe is running from:
MsgBox "The application is running from " & App.Path
Today's code snippet returns a list of information about the current
Copy & Paste Code:
Debug.Print "Application Name: " & App.Title
Debug.Print "Running From: " & App.Path
Debug.Print "Version = " & App.Major & "." & App.Minor & App.Minor
Some Notes about the App Object:
You can use the App.PrevInstance property to prevent your application from being run more than once on a single machine:
You can open a local file from the application's folder without knowing what path the application is running from:
If App.PrevInstance = True Then
MsgBox App.Title & " is already running.
Open App.Path & "customer.dat" For Input As #1
The App Object makes it easy to do some things that otherwise would be very difficult to do in VB. The App.Path property is
especially helpful when creating applications that manipulate files. Any comments about this article are welcome.