Visual Basic is best known for being a Windows Forms Application programming language. In the previous articles we only discussed about Console Applications which ran on CMD windows. It is necessary to first get familiar with the syntax used in Visual Basic and then go on to building Windows Applications.
To Start coding Windows Forms Application, click on New Project and then select Windows Forms Application, name it and click ok.
A simple Windows Forms Application platform in Visual Basic 2010 will simply look like;
How Visual Basic Looks Like in Windows Forms Application?
- Menu-bar and Toolbar: Which includes the Menu and all the tools needed to modify your project. An important part of the toolbar here is the toolbox which is also accessible with (Ctrl + Alt + X).
- Side Bar: It includes the Toolbox which brings you all the tools you need to build a useful Windows Forms Application project. You can also find the Data Sources in the side bar.
- Work Area: This is the main platform where the project has to be developed. It includes the Design Window and the form Window both.
- Solution Explorer: It contains all the necessary information about the project you are working on. Moreover; it defines the path of the project.
- Properties: This is the properties windows. All the characteristics of the Windows Forms Application can be utilized here. As we move further and build different Windows based Applications, we will be explaining the toolbox and property windows more.
- Error List: includes the errors and faults in the piece of code you have built and gives you the possible warnings that may result into an error. It also includes messages.
It has all the necessary and additional tools which are necessary to modify your forms and projects. Whenever you need any tool you just double click on it or drag and drop it in your form. It is important to remember that all the tools in the toolbox can be modified according to the choice of the programmer in the properties window. Some of the frequently used and basic tools in the toolbox are:
Button: It is used to create a button which can help you executing pieces of codes.
Check Box: Gives you the chance to check mark certain entities.
Checked List Box: It is used to create a list of items where you can check mark your choices.
Combo Box: Creates a list of items that can be scrolled.
Date Time Picker: Creates a Date & Time in the windows you have created.
Label: It is only used to give labels to other entities or tools used in the form.
Link Label: Gives the user a chance to link a website or something to the form.
This window is used to modify the entities or tools used in the form. This modification can be in the form of changing the name, changing the size, putting a background color or image for the form, placing the entities to the right place in the form, and etc. As much as you play with the properties windows you get familiar with it and you can design the suited choice of your Application.
Check also: [button link=”http://codejow.com/web-design-tutorials-html5-elements/” size=”default” icon=”fa-vimeo-square” side=”left” target=”” color=”7cb770″ textcolor=”ffffff”]Elements in HTML5[/button]
How to create forms and write codes in Windows Forms Application?
- Create your form
- From the ToolBox, pick a button for your form.
You can change the properties of the button from the properties windows. For the button we have picked we have changed its name and the text on it. Check below:
Text on the Button Changed:
- Double click on your form and the code window will open. It will load your form.
- In the design window, double click on the button you just created. It will create a separate sub for the button in the code window.
- Create a MessageBox in the code window and type in your message there. As below:
Visual Basic1MessageBox.Show("Welcome to CodeJow.Com!", "Welcome")
- Run your form or project.
Once you run your project, a window will pop up. It will contain the button you created. If you click on the button, it will show the message that you had typed in it.
Check also: [button link=”http://codejow.com/math-operators-getting-user-input/” size=”default” icon=”fa-play-circle” side=”left” target=”” color=”4d69b7″ textcolor=”ffffff”]Math Operators and Getting User Inputs in Visual Basic[/button]
“Welcome” Program in Windows Forms Application:
Public Class Form1
' This is the form load code!
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' This is the code for the button!
Private Sub btnWelcome_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
' The first part is the message and the second part is the title!
MessageBox.Show("Welcome to CodeJow.Com!", "Welcome")
Looking forward to receiving your great responses and ideas on our articles.