Programming 2. With Visual Studio. NET development "Hello world!" Program:
We know that "Hello world" is generally a command-line program, and this program is in Visual Studio. NET is called "console program". The following is visual Studio. NET Authoring Console "Hello world! "Specific steps of the program:
(1), starting visual Studio. Net.
(2), select Menu "File" | "new" | "Project", pop-up "New Project" dialog box.
(3), set the project type to Visual basic project.
(4), set "template" to "Console Application".
(5), enter "Hello World" in the Name text box.
(6), enter "E:\VS" in the text box "position". NET project, and then click OK, Visual Studio. NET creates a console application project according to the parameters set above, as shown in Figure 01.
New project interface for "Hello World" console program
(7), in the Solution Explorer window, double-click the Module1.vb file to enter the editing interface of the Module1.vb file.
(8), Visual Studio. NET has already generated the main () function. Add the following line of code to the main () function created by the system:
Console.WriteLine ("Hello world!")
(9), select the "File" | "Save Module1.vb" menu or press the shortcut key Ctrl+s, save the changes.
(10), click the shortcut key CTRL+F5 run the program can be shown in Figure 02 Run the interface:
Picture: The running interface of the Hello World console program
Use visual Studio with the above visible. NET writing console "Hello world!" program, just enter one line of code from start to finish, Visual Studio. NET automates the process of compiling and joining source programs, avoiding the distress of compiling commands at a command prompt. Not only this visual Studio. NET automatic syntax detection, not only to bring convenience to programmers, but also to avoid the spelling caused by unnecessary errors. And so on. These are more than the command-line editor to write Visual Basic. NET program to be convenient and concise.
"Hello world! "The program is a console program, and in the later chapters the type of program is primarily a Windows application (generally referred to as the WinForm program). Take advantage of visual Studio. NET writing WinForm application and console application steps are basically similar. The following is a brief introduction to Visual Studio. NET writes the basic steps of the WinForm type of "Hello World" program.
3. "Hello world!" WinForm version of the program:
"Hello world!" The WinForm version of the program is the name I took. This program is also the output "Hello world!" String, which is not implemented in the command prompt line, but by clicking a button in the program, a message box pops up and displays "Hello world!" in a message box. String. Here is "Hello world!" Specific steps for the WinForm version of the program:
(1), starting visual Studio. Net.
(2), select Menu "File" | "new" | "Project", pop-up "New Project" dialog box.
(3), set the project type to Visual basic project.
(4), set "template" to "Windows Application".
(5), enter "Hello_world program WinForm version" in the Name text box.
(6), enter "E:\VS" in the text box "position". NET project, and then click OK, Visual Studio. NET creates a Windows Application project according to the parameters set above, as shown in Figure 03.
Figure: "Hello World" New project Interface for Windows applications
(7), select Windows Forms component in the Toolbox and drag a button component from it to the Form1.vb window, which is named Button1, and double-click the Button1 component that you dragged into Visual Studio. NET switches the window to the Form1 design window and automatically generates the corresponding code for the Button1 click event.
(8) Add the following code to the code area of the Button1 click event, and the following code function is to eject "Hello world! "Prompt box.
MessageBox.Show ("Hello world!")
(9), select the "File" | "Save Form1.vb" menu or press the shortcut key Ctrl+s, save the changes.
(10), select "Build" | "Generate Hello_world program WinForm version" menu, then visual Studio. NET compiles, connects the source program automatically, and generates the Hello_world program WinForm version of the execution file.
(11), select the "Debug" | "Start" menu or click the shortcut "F5", then start running the Hello_world program WinForm version of the program, click the program "Button1" button, then pop-up "Hello world! Prompt box, as shown in Figure 04.
Figure: "Hello_world" program WinForm version of the operating interface
So far Hello_world program WinForm version of the program to complete the work. For other WinForm programs, the basic steps to write are similar, except that more components, classes, and other calls are involved in the program. Is nothing more than the deformation and the combination of the above steps.
Five Summarize:
This article describes visual Basic. NET's superiority and its main difference from the previous version of Visual Basic. and install Visual Basic. NET development tools Visual Studio. NET and the use of visual Studio. NET developed two different types of visual Basic. NET application, the basic steps and methods. Of course, it is not an article that can be accomplished with complete mastery and mastery of the content. In the following sections, the Step-by-step introduction will be combined with more specific examples.
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.