Technical Training
VB.NET 2005Application Class and Message Class
Using Application Class
Visual Basic 2005 introduces a speedy way to access many important classes relating to the Computer on which the application is running, the user running it, the application itself, its forms and any associated web services. The best part of it all is that you can access it all using the new My object. The new My object has added features that help the programmer to gain access to some functionality that was really hard to achieve.
My.Application Object contains information about running application, such as the title, working directory, version, and the common language runtime (CLR) version in use. It also gives access to environment variables, allow you to easily write to the local application log or to a custom log, and so on.
You can access the Application information easily as can be seen in the following lines of code
My.Application.AssemblyInfo.DirectoryPath
My.Application.AssemblyInfo.ProductName
My.Application.Log.WriteEntry(“Application Starting”, EventLogEntryType.Information, Nothing)
The above lines of code will retrieve this information from the assembly which can used by the application on run time.
The following table gives the properties and methods of the My.Application Object
ApplicationContext Gives access to the context associated with the current thread.
AssmblyInfo Allows easy access to data from the AssemblyInfo.vb file, including CompanyName, ProductName, Title and Version.
ChangeCurrentCulture Allows Change the culture in which the current thread is running, which affects such things as string manipulation and formatting
ChangeCurrentUICulture Allows changing the culture that the current thread uses for retrieving culture-specific resources
CommandLineArgs Return a collection of command-line arguments
CurrentCulture Returns a collection of command-line arguments
CurrentDirectory Returns the folder where the application resides
CurrentUICulture Returns the culture that the current thread is using for retrieving culture-specific resources
DoEvents Causes all messages in the message queue to be processed
GetEnvironmentVariable Returns a specific environment variable on the local machinge
IsNetWorkDeployed Returns True if the application was network-deployed else returns False.
Log Allows writing to application log on the local machine
MainForm A read-write property that allows setting or getting the form that the application will use as its main form
Run Sets up and starts the VB Startup/Shutdown Application model
SplashScreen Lets setting or getting the application's splash screen
Using the MessageBox class
Message boxes are often used objects. They are derived form Form Class, displayed modally and used to take user’s acknowledgement and also inform the user or alert the user of any thing that needs to be informed or alerted.
You cannot create a new instance of the System.Windows.Forms.MessageBox class. To display a message box, call the static method System.Windows.Forms.MessageBox.Show. The title, message, buttons, and icons displayed in the message box are determined by parameters that you pass to this method.
The following example shows how to use a System.Windows.Forms.MessageBox to inform the user of a missing entry in a System.Windows.Forms.TextBox.
This example assumes that the method is called from an existing form with a System.Windows.Forms.Button and a System.Windows.Forms.TextBox on it.
Protected Sub button1_Click(sender As Object, e As System.EventArgs)
If textBox1.Text = "" Then
MessageBox.Show("You must enter a name.", "Name Entry Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation)
Else
' Code to act on the data entered would go here.
End If
End Sub
VB.NET 2005
- VB.NET 2005 Free Training
- The .NET Framework Architecture Part 1
- The .NET Framework Architecture Part 2
- Application Class and Message Class
- Implementing Class Library Object
- Visual Studio.NET Namespaces
- .NET Assemblies
- Differences between VB.NET 1.0 and VB.NET 2.0
- Introducing VB.NET Windows Forms
- Visual Studio Windows Forms Designer
- Exploring the Forms Designer generated code
- Setting and Adding Properties to Windows Form
- Implementing Inheritance
- Event Handling In Visual Basic .NET
- Building Graphical Interface elements
- .NET Common Windows Forms Controls Part 1
- .NET Common Windows Forms Controls Part 2
- Common Controls and Handling Control Events
- DomainUpDown and NumericUpDown Controls
- Dialog Boxes in Visual Basic .NET
- Visual Studio Adding Controls to Windows Form
- VB.NET Validation Controls
- Working with Menu Controls
- VB.NET MDI Applications
- .NET Exceptions
- VB.NET Creating and Managing Components Part 1
- VB.NET Creating and Managing Components Part 2
- Simple Data Binding
- .NET Complex Data Binding
- .NET Data Form Wizard
- Data Manipulation with ADO.NET
- SQL Server Stored Procedures
- SQL Server Ad Hoc Queries
- Finding and Sorting Data in DataSets
- ADO.NET Object Model
- Working with DataSets
- Using XML Data
- Working with File System in .NET
- Creating Web Service
- Instantiating - Invoking Web Services, Creating Proxy Classes with WSDL
- Web Reference and Web Services
- Web Services - SOAP, WSDL, Disco and UDDI
- Web Application Testing in VB.NET 2005
- Web Application Tracing and Debugging
- Working with Legacy Code and COM Components
- ActiveX Controls and Legacy Code
- Windows Application Testing
- VB.NET Windows Application Testing
- Tracing VB.NET Windows Application
- Debugging Windows Applications In Visual Studio.NET 2005
- Deploying Windows Applications In Visual Studio.NET 2005
- Customizing Setup Project in Visual Studio.NET 2005
- Shared Assembly
- Microsoft .NET Creating Installation Components
- The Registry Editor in Visual Studio.NET 2005
- The File Types Editor







