Arithmetic Operators

Submitted by: 

In programming, the Mathematical operations are very useful because most of the time we are dealing with mathematical concepts in programming. We know that computers can perform a mathematical calculation much faster than humans. Also the computer doesn’t have the capacity to do calculations without receiving any instructions from the computer user. Using Visual Basic, we are able to give instructions to the computer to perform mathematical operations such as Multiplication, Division, Addition, Subtraction and other kinds of arithmetic operations.

List of Arithmetic Operators in Visual Basic.

Sysmbol Name
* Multiplication
/ Division
+ Addition
- Subtraction
\ Integer Division
Mod Modolo
^ Exponentiation

This time, we’re going to create a program performing the Arithmetic Operators. To do this, open Visual Basic and create a new project then save it as “Arithmetic Operators”. Next, add two textbox, six labels and a button.

Deigning the Object Properties.

Object Property Settings
Textbox1 Name txtinput1
Textbox2 Name txtinput2
Label1 Name lblmul
Text 0
Label2 Name lbldiv
Text 0
Label1 Name lbladd
Text 0
Label1 Name llblsub
Text 0
Button1 Name btncompute
Text Compute

Then,arrange all object looks like as shown below.

At this time, we will add functionality to our application. To do this, double click the” Compute” button and add the following code:

  1. Dim input1 As Integer
  2. Dim input2 As Integer
  4. input1 = txtinput1.Text ' assign value to a variable
  5. input2 = txtinput2.Text
  7. lblmul.Text = input1 * input2 ' compute for Multiplication
  8. lbldiv.Text = input1 / input2 ' compute for Division
  9. lbladd.Text = input1 + input2 ' compute for Addition
  10. lblsub.Text = input1 - input2 ' compute for Subttraction

After adding the code above, you can now test your application by pressing “F5”.


nice tnx uploader

THanks ! You are pRO

Add new comment

Filtered HTML

  • Web page addresses and e-mail addresses turn into links automatically.
  • You may insert videos with [video:URL]
  • Allowed HTML tags: <a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd> <table> <tr> <td> <th> <img> <h1> <h2> <h3> <iframe> [video]
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>, <asp>, <c>, <cpp>, <csharp>, <css>, <html4strict>, <java>, <javascript>, <mysql>, <php>, <python>, <sql>, <vb>, <vbnet>. The supported tag styles are: <foo>, [foo].
  • Lines and paragraphs break automatically.

Plain text

  • No HTML tags allowed.
  • Lines and paragraphs break automatically.
This question is for testing whether or not you are a human visitor and to prevent automated spam submissions.