robotics-university.com | Hello my friends! I’m great to learn together with you. Today I will guide you to starting build a new windows application project using Visual Basic .Net. For the software builder, I use Visual Studio 2015.
For the first project, I will guide you to make a Windows application using Visual Basic .Net that have function to open a “Welcome to Visual Basic .Net” window when a “Show Greeting” button pressed. Have you ready to start? If yes, let’s follow all of its steps one by one, in order you exactly understand all of its technical guide and its function.
A. Create a New Windows Application Project Work Environment
First, make sure that Visual Studio 2015 has installed in your computer (install it first if hasn’t installed). After that, open Visual Studio 2015 from program file menu (All Programs >> Visual Studio 2015), or from Visual Studio 2015 shortcut if it has available on your computer desktop.
To start a new project, on the Visual Studio “Start Page” tab, select “New Project,” so a New Project windows opened. See figure 3 and figure 4!
Figure 3. Create new Visual Basic Net (VB net) project
On New Project windows, select “Templates” root and then select “Visual Basic” root too. See figure 4!
Figure 4. Select Visual Basic template
So Visual Basic application template options opened. See figure 5! Then select “Windows Forms Application.” See figure 5!
Figure 5. Visual Basic application template options
After that, give the name of your windows application project. Type the name on the name field. For example, I type “My First Project” for this new project. For your information, the solution name will generate automatically once you type the project name. It is mean if you give the project name with “My First Project,” so on the solution name field will automatically type “My First Project” for the solution name. See figure 6!
Figure 6. Give the name of the VBnet project & the solution
Next, determined directory (folder) where you will use to store your windows application project files. Click “Browse” button on the right side of the location field and find a directory that you want. See figure 7, figure 8, and figure 9!
Figure 7. Click browse to find a directory
Figure 8. Select a folder/directory
Figure 9. Click OK, to continue
After you has finished with the project name, location, and solution name, next press “OK” button, in order Visual Studio will prepare a Visual Basic .Net work environment for you. The preparation process will need several time, so just wait it and don’t disturb the progress. See figure 10!
Figure 10. Generation process of VB-Net project by Visual Studio 2015
Figure 11. Visual Basic .Net environment
Figure 11, show the prepared Visual Basic .Net work environment. From here, you can start your activities to create a windows application project using Visual Basic .Net.
B. Start to Create a New Project
Let’s start working to create a new windows application with Visual Basic .Net work environment. Follow every single step carefully!
Step 1: Change the Project Form Title
To change the windows application title. The first, left-click the windows application form and then go to properties area. See figure 13! Found the “Text” properties item and click the “Form1” text to change it with your words. On this example, I change the title with “Welcome to VB .Net.” Then press Enter key and see the result as displayed on the figure 14.
Figure 13. Properties: Edit the form name
Figure 14. The form name has been changed
Step 2: Add a Toolbox - Button
To add a toolbox item from toolbox, there can be done with two method. The first method, you can do it by select a toolbox item with left-click your mouse cursor, hold it, drag it on the top of windows application form, and release it. After that, the toolbox item will available on the top of window application form. See figure 15!
Figure 15. Add a toolbox item (button) - 1st method
The second method, you can do it by double-left-click a toolbox item, so the toolbox item will available on the windows application form automatically. See figure 16!
Figure 16. Add a toolbox item (button) - 2nd method
And the third method, you can do it by left-click a toolbox item once, after that move your mouse cursor on the top of the windows application form. To start place a toolbox item (Button), left-click and hold on a point (1st point), then drag your mouse cursor to another point (2nd point), and release your left-click on the second point. After that the toolbox item (button) will available on the windows application form. See figure 17!
Figure 17. Add a toolbox item (button) - 3rd method
Step 3: Edit the Button Object Properties
To set the button object properties, you can do it on the Properties area. First, left-click the button object once. Then go to the properties area and set/edit some properties items like BackColor, Font, ForeColor, Text, and Size with follow the value or the setting that I have prepared to you on the table 1 below. Also see figure 18!
Table 1. Button object properties setting
Figure 18. The button object properties setting
If the properties setting has been finished, you can see the result. The display of the button object as you can see on the figure 19 below.
Figure 19. The display of the Toolbox item (Button) after its properties edited
Step 4: Handle the Button Object Using Visual Basic .Net Code
To handle the button object in order it can do an action (To show the greeting message box) when it is clicked, we have to insert some Visual Basic .Net codes in it. Here I will show you the steps. First, double-click the button object (See figure 20!), so a text/code editor page/tab will be opened. See figure 21!
Figure 20. Click the button object to open VB .Net text editor
Then type several line of Visual Basic .Net codes below on the “Button1_Click_1” sub-routine (sub-program).
As displayed on figure 22 below.
Figure 22. Visual Basic .Net code to handle a button object
After your windows application design and its Visual Basic .Net code has finished already, then save your new project. Select the “File” menu then select “Save All” option to save both the windows application design (the form) and the visual basic .net codes together, or use shortcut-key [Ctrl + Shift + S]. See figure 23!
Figure 23. Save all items of your new project
Step 5: Build/Rebuild Your Windows Application Project Code
As on the other programming projects, in order your Visual Basic .Net code can run (debug) and you know there is an error or not, you have to build or compile it first. Select “Build” menu, then select “Build Solution” option. After that, wait for a moment while the building process is running. See figure 24! If you want to use the shortcut to launch the Visual Basic .Net code building process, you can use shortcut-key [Ctrl + Shift + B].
Figure 24. Build (compile) the Visual Basic .Net code of a windows application
Figure 25. Output: Visual Basic .Net code building process successfully done
If the building process running successfully, on the “Output” area will show an information that the Visual Basic .Net code building process succeeded with zero failed. See figure 25! If the Visual Basic .Net code building process failed and on the output area show one or more error, so you have to correct the occurred error and then rebuild the code. Select the "Build" menu, then select the "Rebuild Solution" option. See figure 24!
Step 6: Run (Debug) Your Windows Application Project
After the Visual Basic .Net code building process succeeded, now is the time for you to run (debug) your windows application project. Select the "Debug" menu, then select the "Star Debugging" option, or use shortcut-key [F5]. See figure 26! Or use start debugging button that available on tool-bar. See figure 27!
Figure 26. Run process of windows application project
Figure 27. Start debugging button on tool-bar
If the debugging process succeeded, your windows application design will appear (See figure 28!) and you can operate it. Is the windows application run as your expectation? If yes, congratulation, you have succeeded build your own windows application using Visual Basic .Net! If no, unfortunately, you have to effort to find the cause.
Figure 28. The debugging environment
If you have been finished with the debugging process, you can stop it. Go to “Debug” menu on the menu-bar, select Debug and then select “Stop Debugging” option, or use key-shortcut Shift + F5. See figure 29!
Figure 29. Stop debugging process
You can also stop the debugging process directly with click the “Stop” button that provide on the tool-bar. See figure 30!
Figure 30. Stop debugging button on tool-bar