How to Add Two Numbers in VB.NET

add two numbers in vb.net

As the name suggests, how to add two numbers in VB.Net is an application that will allow the user to just enter the numbers to be added and the result will be displayed in just one mouse click. Visual basics dot net is an object oriented programming language which is implemented based on the .NET framework. This programming language is designed to meet the need for the web services and web development. This programming language supports multi threading and also web development services with great ease. It helps in managing the large amounts of data through the web with great ease.

How to Add Two Numbers in VB.NET

This is the simple program which will explain how to add two numbers in VB.NET. Adding two numbers is not complicated but you have to work in some basic programs. Here we created 3 text boxes. Two text box to enter number 1 and number 2 and 3rd text box to display the total. One button added, Onclick event of the button it displays the sum of number 1 and number 2 in the total text box.

This code is very simple and its created in Visual studio 2012. Kindly add the following tools in the form:

  • Insert three labels and change its text property- Number 1, Number 2 and Total
  • Name of the number 1 Text box – txtnum1
  • Name of the number 2 Text box – txtnum2
  • Name of the Total text box – txttotal
  • Name of the button – btntotal

The two textboxes are txtnum1 and txtnum2 contains numbers. The val function converts string to number. The following code created in the btntotal click event:

Private Sub btntotal_Click(sender As Object, e As EventArgs) Handles btntotal.Click
                txttotal.Text = Val(txtnum1.Text) + Val(txtnum2.Text)
End Sub

After entering source code run your program and check its working properly or not.

Download this source code:

download

This video will explain how our source code works and how to create this simple example code:

Do you have any queries?

This site uses Akismet to reduce spam. Learn how your comment data is processed.