vb.net tutorial

How to Calculate Two Columns in DataGridView

In my previous tutorial using DataGridView Control I explained on “How to Differentiate Two Cell Values in DataGridView Control”. This time I will teach you on how to calculate two columns in DataGridView Control.

This tutorial is very useful if you want to make a total of the two columns. For example a total of “Qty” and “Sales Price” Column.

Additionally, we will make a total of the “Amount” column.

How to Display Data in Windows Forms

In order to display data in windows forms all you need to do is drag Items from the Data Sources. For more information, see How to Add New Data Source.

Before you drag the Items (i.e. table name) make sure that you select the display type and type of control that you’d like to appear in the Windows Forms.

To do this expand the Item name and the arrow down to select the display type and type of control which you would like to appear.

Display type

How to Add Windows Forms

Before we begin binding our database using Windows Form please take a look on this tutorial on how to add new windows forms to your project.

Windows Forms serves as a container for all the controls that you’d like to add. Examples are TextBox, Label, Button, CheckBox, ComboBox, etc.

When you create a new project, visual studio automatically provides you one windows forms which you can use right away, run it, or compile or project but without anything in it. It just a plain form waiting to be filled with controls.

To add a Windows Form

How to Add New Data Source

One of the coolest features of Visual Studio .NET is the ability to bind a database into Windows Forms easily using DataSet. Since VB 6.0, I’m waiting for this kind of feature to be implemented in VB.NET. I am used with MS Access before and seem that VB.NET and MS Access has no difference when it comes to DataBinding.

There are many ways to bind your data. You can use the old fashion which is hard-coding, but this is out the scope of this tutorial. Why use hard-coding if you can do it easily using drag and drop operation?

How to Create a Windows Application Project

In order to create an application in Visual Basic .NET like Payroll System, Accounting System, Enrollment System, Calculator, Point of Sale System, and Library System you need to create a project called “Windows Application”.

If you are new to programming and want to learn Visual Basic, you will probably confuse with so many option to choose in starting a Visual Basic Editor.

Please look at the screen below.

How to Create Database Relationships

In my previous tutorial I discuss on “How to Add Table to Your Existing Database”. Now, I will explain to you on how to create database relationships between one or more tables. Relationship is very important to prevent data inconsistency in your database. For example, you cannot add record in the related table without first adding a record in the primary table.

A relationship exists when two tables are related using a primary key and a foreign key.