1.3 Creating a Visual Basic 2022 Project
To create a Visual Basic 2022 project, launch Microsoft Visual Studio 2022 to bring up the Visual Studio 2022 Start Page, as shown in Figure 1.5
Figure 1.5 Visual Studio 2022 Start Page
The Visual Studio 2022 start page offers a much simpler UI than VS2019, it comprises four options: clone a repository, open a project or solution, open a local folder or create a new project.
Let us create a new project by clicking the Create a new project option. You will see the Create a new project template page, as shown in Figure 1.6. There are a dozen templates to choose from, but since the book is about
Visual Basic 2022 programming, scroll down to select WPF application, as shown in Figure1.6.
Figure 1.6 Create a new project template
Next, select the Windows Forms App (.Net Framework) template as we want to develop a Windows desktop project. After selecting the template and clicking the Next button, the project configuration page appears, as shown in Figure 1.7. You can configure your project by typing the project name and selecting a few other options.
Figure 1.7 Configuring Project
At the bottom of this dialog box, you can change the default project name WindowsApplication1 to some other name you like, for example, My First Visual Basic 2022 Application. After renaming the project, click OK to continue. The Visual Basic 2022 IDE Windows will appear, as shown in Figure 1.8. Visual Basic 2022 IDE comprises a few windows, the Form window, the Solution Explorer window, and the Properties window. It also consists of a toolbox which contains many useful controls that allows the programmer to develop his or her Visual Basic 2022 programs.
Figure 1.8 The Visual Basic 2022 IDE
The Toolbox is not shown until you click the Toolbox tab. When you click the Toolbox tab or use the shortcut keys Ctrl+Alt+x, the common controls Toolbox will appear, as shown in Figure 1.9. You can drag and move your toolbox around and dock it to the right, left, top or bottom of the IDE.
Figure 1.9 Visual Basic 2022 Toolbox
Next, we shall proceed to show you how to create your first VB2022 application. First, change the text of the form to ‘My First VB 2022 Application’ in the properties window; it will appear as the title of the application. Next, insert a button and change its text to OK. The design interface is shown in Figure 1.10
Now click on the OK button to bring up the code window and enter the following statement between Private Sub and End Sub procedure, as shown in Figure 1.11.
MsgBox("My First Visual Basic 2022 App")
Clicking the Start button on the toolbar or press F5 to run the application will launch the runtime interface, as shown in Figure 1.12. Executing the application by clicking the OK button will bring up a dialog box that displays the “My First Visual Basic 2022 App" message, as shown in Figure 1.13. The function MsgBox is a built-in function of Visual Basic 2022 which can display the text enclosed within the brackets.
Figure 1.11 Visual Basic 2022 Code Window
Summary
- In section 1.1, you have learned about the history of Visual Basic 2022
- In section 1.2, you have learned how to install and launch Visual Basic Studio 2022
- In section 1.3, you have learned how to launch the new project dialog and the Visual Basic 2022 IDE. You have also learned how to write your first program.
0 Comments
Thanks for your comment.
i will reply you soon.