Export (0) Print
Expand All
Expand Minimize

App Object for Visual Basic 6.0 Users 

This topic compares the Visual Basic 6.0 App object with its equivalent in Visual Basic 2005.

The App object in Visual Basic 6.0 is a global object used to set or retrieve information about the application. There is no direct equivalent for the App object in Visual Basic 2005. However, most of the properties, methods, and events can be mapped to equivalent members in the .NET Framework.

Conceptual Differences

Version Information Properties

The App object's Version Information properties are replaced by Assembly attributes in Visual Basic 2005. Version Information properties are set in the Project Properties dialog box. Assembly attributes are set in the Assembly Information dialog box, which is available by clicking the Application Information button on the Application tab of the Project Designer.

NoteNote

Version Information properties are stored in the Project (.vbp) file, which you can edit using a text editor such as Notepad. Assembly attributes are stored in the AssemblyInfo.vb file and can be edited in the Code Editor.

File Description Property

The Visual Basic 6.0 App object has both FileDescription and Title properties; FileDescription determines the description text that appears in Windows Explorer.

In Visual Basic 2005, there is no FileDescription attribute. Instead, the Title attribute determines the descriptive text that appears in Windows Explorer.

HelpFile Property

The HelpFile property in Visual Basic 6.0 specifies a Help file at the application level.

In Visual Basic 2005, Help files are specified on a per-form basis using a HelpProvider component. For more information, see Help Support for Visual Basic 6.0 Users.

Version Properties

The Major, Minor, and Revision properties in Visual Basic 6.0 are used to return a three-part version number for an application.

In Visual Basic 2005, version information also includes a Build property, and the complete four-part version number can be retrieved using a single Version property. For more information, see Version Numbering for Visual Basic 6.0 Users.

Title Property

The Title property of the App object in Visual Basic 6.0 can be changed programmatically; doing so determines the name that appears in the Windows Task Manager.

In Visual Basic 2005, the Title attribute is read-only. The Text property of the application's main form determines the name that is shown in the Task Manager. You can set the Text property programmatically, but the text in the title bar of the form will change as well.

TaskVisible Property

In Visual Basic 6.0, the TaskVisible property of the App object determines whether an application appears in the Windows Task List (Windows 9x) or the Task Manager Applications tab (Windows 2000 or later). The property is commonly used to prevent a user from closing an application that was designed to run as a background task. In most cases, the TaskVisible property is used with applications that do not display user interfaces.

In Visual Basic 2005, there is no equivalent for the TaskVisible property; however, you can create a Windows Service or a Console Application that will not show up in the task list.

PrevInstance Property

The PrevInstance property in Visual Basic 6.0 determines if an instance of the application is already running. Typically you call PrevInstance on application startup and abort the application if it returns true.

There is no direct equivalent for PrevInstance in Visual Basic 2005. You control whether or not multiple instances of an application are allowed by setting the Multiple Instance property on the Application tab of the Project Designer. At run time, a NextInstanceStarted event is raised when a user tries to start another instance of the application. You can add code to this event handler to activate the first instance of the application.

Additional Differences

There are a number of App object properties in Visual Basic 6.0 that concern ActiveX components, OLE automation, and other technologies that are now obsolete and are not supported in Visual Basic 2005. They are noted in the App Object Property Equivalencies table later in this topic.

Code Changes for the App Object

The following code examples illustrate the differences in coding techniques between Visual Basic 6.0 and Visual Basic 2005 for some common uses of the App object.

Code changes for displaying an application's version number

The following example demonstrates retrieving an application's version number and displaying it in a label.

' Visual Basic 6.0
Label1.Caption = "Version: " & App.Major & "." & App.Minor & "." _
& App.Revision
' Visual Basic 2005
Label1.Text = My.Application.Info.Version.ToString()

Code changes for determining an application's path

The following example demonstrates how to display an image file that is stored in the application's folder by retrieving the path to the executing application.

' Visual Basic 6.0
Picture1.Picture = LoadPicture(App.Path & "\Logo.jpg")
' Visual Basic 2005
PictureBox1.Image = System.Drawing.Bitmap.FromFile( _
  My.Application.Info.DirectoryPath & "\Logo.jpg")

Code changes for preventing a second instance of an application from running

The following example demonstrates implementing a single-instance application.

' Visual Basic 6.0
Private Sub Form_Load()
    If App.PrevInstance = True Then
        MsgBox("The application is already running!")
    End If
End Sub
' Visual Basic 2005
' Assumes that the Make Single Instance Application checkbox in the 
' Project Designer has been checked.

Private Sub MyApplication_StartupNextInstance(ByVal sender As Object, _
ByVal e As Microsoft.VisualBasic.ApplicationServices. _
StartupNextInstanceEventArgs) Handles Me.StartupNextInstance
    MsgBox("The application is already running!")
End Sub

App Object Property Equivalents

The following table lists all properties and methods of the Visual Basic 6.0 App object and their Visual Basic 2005 equivalents.

Visual Basic 6.0 Visual Basic 2005 Equivalent

Comments

My.Application.Info.Description Property

CompanyName

My.Application.Info.CompanyName Property

EXEName

My.Application.Info.AssemblyName Property

FileDescription

My.Application.Info.Title Property

HelpFile

New implementation. Use a HelpProvider component. For more information, see Help Support for Visual Basic 6.0 Users.

HInstance

GetHINSTANCE

LegalCopyright

My.Application.Info.Copyright Property

LegalTrademarks

My.Application.Info.Trademark Property

LogEvent method

WriteEntry Method (My.Application.Log and My.Log)

LogMode

LogPath

New implementation. For more information, see Logging Information from the Application.

Major

My.Application.Info.Version Property

NoteNote

The format for version numbers is different in Visual Basic 2005. For more information, see Version Numbering for Visual Basic 6.0 Users.

Minor

My.Application.Info.Version Property

NoteNote

The format for version numbers is different in Visual Basic 2005. For more information, see Version Numbering for Visual Basic 6.0 Users.

NonModalAllowed

New implementation. This is a read-only property related to ActiveX .dll files. The common language runtime automatically manages this behavior.

OleRequestPendingMsgText

OleRequestPendingMsgTitle

OleRequestPendingTimeout

OleServerBusyMsgText

OleServerBusyMsgTitle

OleServerBusyRaiseError

OleServerBusyTimeout

No equivalent. These properties relate to OLE automation, which is not supported by Visual Basic 2005.

Path

My.Application.Info.DirectoryPath Property

PrevInstance

IsSingleInstance

NoteNote

The IsSingleInstance property is a Protected property. It can only be set at design time in the Project Designer by checking or clearing the Multiple Instance check box.

ProductName

My.Application.Info.ProductName Property

RetainedProject

New implementation. Visual Basic 2005 cannot retain a project in memory.

Revision

My.Application.Info.Version Property

NoteNote

The format for version numbers is different in Visual Basic 2005. For more information, see Version Numbering for Visual Basic 6.0 Users.

StartLogging method

New implementation. For more information, see Logging Information from the Application.

StartMode

No equivalent. This property concerns creating ActiveX components, which is not supported in Visual Basic 2005.

TaskVisible

New implementation. To create an application that does not appear in the Task Manager, create a Windows Service or Console Application project.

ThreadID

New implementation. This property returned the ID of the executing thread; the threading model is significantly different in Visual Basic 2005.

Title

My.Application.Info.Title Property

UnattendedApp

New implementation. For unattended applications in Visual Basic 2005, create a Console Application project.

Upgrade Notes

When an application is upgraded from Visual Basic 6.0, only the Major and Minor properties are upgraded; Visual Basic 2005 assigns new values to the Revision and Build properties.

See Also

Community Additions

ADD
Show:
© 2014 Microsoft