Visual Basic 2005 New Function Reviews - My.ApplicationMY Namespace

zhaozj2021-02-16  95

Keywords: VB8.0 VB.NET VB2005 My Namespace

Visual Basic is different from Visual C #, and Visual C is more than rapid development and more non-professional developers and programs. Visual Basic 2005 This "MY" is an extremely excellent design that helps developers quickly utilize the various functions in the .NET Framework. Saying what my in the end, in fact it is a project-related namespace, where the content is helped with you.

Before My appears, .NET Framework has a powerful and rich library, learning these class libraries is not a relaxed thing. Many VB or VC developers are always accustomed to implementation of their own implementation or by calling Windows APIs for the first time. The reason is that the .NET class library is too large to be too dispersed, many common functions are mixed with those who are less commonly used. For example, a method of obtaining milliseconds starting from the day (often used to do random numbers) actually with the setting environment variable function in the Environment class, rather than "look like" system.timers, TimeSpan or DateTime and other namespaces or types. Many developers are not familiar with class libraries, so they repeatedly developed .NET Framework function over and over again. In order to solve this problem, Visual Basic Team is designed with MY namespace, which will pick up the most commonly used function in .NET Framework, then put together according to the most easily understood logical structure. When you go deep into my namespace, you will find that those features can be imagined in the path you can imagine.

My namespace mainly contains six major parts such as My.Application, My.computer, My.Resources, My.User, My.Forms, My.Webservices. You can enter my keyword to find them, or import my namespace, whose syntax is:

IMPORTS project name .my

In all classes or objects in my namespace, my.application is an object related to the currently running application. This time you introduce my.application. My.Application provides high features, such as the current application's main thread, main window, version, or company copyright information, culture, and language setting, path, and command line, event log even Splash Screen information. The following table lists all the features of My.Application.

MY.Application Members describe the context of the ApplicationContext application, including information of the main thread and the main form, including the version, copyright, title, product name, and executable name, ChangeCurrentCulture, change the current cultural settings, such as currency and Time Format CHANGECURRENTUICURURE Changes the current user interface culture setting, such as displaying language and word CommandLineargs, a read-only collection, returns the command line parameters of the current application. These parameters have been separated, and there is no need to manually divide the value of the COMMAND function as it is. All Windows messages Exit CurrentCulture Returns the current cultural settings CurrentDirectory return to the application's current directory CurrentUICulture Returns the current user interface culture set Deployment return applications that are deployed in accordance with the ClickOnce method of Deployment objects DoEvents execution stored in the Windows message queue exit the application GetEnvironmentviriable Gets the value of the environment variable by the name of the environment variable. ISNetworkDeployed returns a value, indicating whether the current application uses network deployment mode log a logging application event log and an exception log tool MainForm current application mainfield OpenForms current application All sets of open forms, with the VB6 Forms collection function Same Run started Visual Basic boot / Close application mode SplashScreen Returns the current application as a window of Splash Screen to note that some of the features in My.Application and The Application object is the same, but My.Application is not only available for Windows Form applications, but many functions can be used in console applications. Let's take a few simple examples to use My.Application:

1. Display a simple about the window.

With My.Application.AssemblyInfo Dim msg As New System.Text.StringBuilder msg.AppendLine ( "Protuct Name:" & .ProductName) msg.AppendLine ( "Company Name:" & .CompanyName) msg.AppendLine ( "Version:" & .Version.tostring) msg.appendline ("Description:" & .description) msgbox (msg.tostring, msgboxstyle.information, "about" & .title) end with

2. Change the title of all the windows that is currently open to environment variable% title%

For Each F AS Form in My.Application.openForms F.Text = My.Application.GetenvironmentvironmentVariable ("Title") doevents () can also be written into my.application.doevents () Next

3, check if you deploy from the network, modify the current user interface culture set to English - USA

If.Application.isnetworkDeployed the my.application.changecurrentunicuiculture ("en-us") Endiff

转载请注明原文地址:https://www.9cbs.com/read-12195.html

New Post(0)