ITSourceCode.com

We Exist to Provide 100% Free Source Code and Tutorials

Custom Search

How to Create the MDAS Calculation in VB.Net

In this tutorial, I will teach you how to create the MDAS calculation in VB.Net and MySQL Database. MDAS are the four fundamentals operation in solving the mathematical equation. MDAS stands for MULTIPLICATION, DIVISION, ADDITION and SUBTRATION.
I’m going to use a Visual Studio 2008 for creating this desktop application.

Let’s begin:
Open the Visual Studio 2008 and create a new Windows Form Application. After that, set the Form just like this.
mdasform
After setting up the Form, double click the “Multiply” Button and set up the formula for the multiplication method.

  1. 'THIS IS FOR MULTIPLICATION
  2.     Private Sub btnmul_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnmul.Click
  3.          'SET THE VAL TO RETURN A NUMERIC VALUE THAT CONTAINS A NUMBER IN A STRING VALUE
  4.         txttot.Text = Val(txtFnum.Text) * Val(txtSnum.Text)
  5.     End Sub

And then, these are the formula for the Divide, Add and Subtract Buttons.

  1. 'THIS IS FOR DIVISION
  2.     Private Sub btndiv_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndiv.Click
  3.         txttot.Text = Val(txtFnum.Text) / Val(txtSnum.Text)
  4.     End Sub
  5.     'THIS IS FOR ADDITION
  6.     Private Sub btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadd.Click
  7.         txttot.Text = Val(txtFnum.Text) + Val(txtSnum.Text)
  8.     End Sub
  9.     'THIS IS FOR SUBTRATION
  10.     Private Sub btnsub_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsub.Click
  11.         txttot.Text = Val(txtFnum.Text) - Val(txtSnum.Text)
  12.     End Sub

After setting up the formula in each corresponding Buttons, go back to the Form Design, double click the Form and disable the TextBox(txttot) in the first load of the Form.

  1. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  2.         txttot.Enabled = False
  3.     End Sub

Finally, these are the full codes that you have made.

  1. Public Class Form1
  2.     'THIS IS FOR MULTIPLICATION
  3.     Private Sub btnmul_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnmul.Click
  4.         'SET THE VAL TO RETURN A NUMERIC VALUE THAT CONTAINS A NUMBER IN A STRING VALUE
  5.         txttot.Text = Val(txtFnum.Text) * Val(txtSnum.Text)
  6.     End Sub
  7.     'THIS IS FOR DIVISION
  8.     Private Sub btndiv_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndiv.Click
  9.         txttot.Text = Val(txtFnum.Text) / Val(txtSnum.Text)
  10.     End Sub
  11.     'THIS IS FOR ADDITION
  12.     Private Sub btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadd.Click
  13.         txttot.Text = Val(txtFnum.Text) + Val(txtSnum.Text)
  14.     End Sub
  15.     'THIS IS FOR SUBTRATION
  16.     Private Sub btnsub_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsub.Click
  17.         txttot.Text = Val(txtFnum.Text) - Val(txtSnum.Text)
  18.     End Sub
  19.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  20.         txttot.Enabled = False
  21.     End Sub
  22. End Class

You can also download the complete source code and run it on your computer.
DOWNLOAD HERE

Facebook Comments

Check Your Domain Ranking

Leave a Reply

Your email address will not be published. Required fields are marked *

ITSourceCode.com © 2016 Frontier Theme

Subscribe For Latest Updates

Signup for our newsletter and get notified when we publish new articles for free!