The Daily Newbie - Using the App Object

Submitted on: 1/17/2015 8:12:00 AM
By: Matthew Roberts (from psc cd)  
Level: Beginner
User Rating: By 6 Users
Compatibility: VB 4.0 (32-bit), VB 5.0, VB 6.0, VBA MS Access
Views: 473
     Explains the basics of using the App Object.


Daily Newbie - 05/01/2001

The Daily Newbie

“To Start Things Off Right”

May 8, 2001

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.

Today’s Topic: The App Object

Name Derived From: "Application"

Used for: 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.

Plain English: Returns information about the running application.

Syntax:X =App.{Property}


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 run from.
  • 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.

  • Methods:

  • 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.
  • Example:

    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 application:

    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:

    If App.PrevInstance = True Then MsgBox App.Title & " is already running. End If

  • You can open a local file from the application's folder without knowing what path the application is running from:


    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.

    Other 25 submission(s) by this author


    Report Bad Submission
    Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
    This submission should be removed because:

    Your Vote

    What do you think of this article (in the Beginner category)?
    (The article with your highest vote will win this month's coding contest!)
    Excellent  Good  Average  Below Average  Poor (See voting log ...)

    Other User Comments

     There are no comments on this submission.

    Add Your Feedback
    Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular article, please click here instead.)

    To post feedback, first please login.