How to Create the MDAS Calculation in VB.Net

0
1230

This tutorial is all about 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.

After setting up the Form, double click the “Multiply” Button and set up the formula for the multiplication method.
[vbnet] ‘THIS IS FOR MULTIPLICATION
Private Sub btnmul_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnmul.Click
‘SET THE VAL TO RETURN A NUMERIC VALUE THAT CONTAINS A NUMBER IN A STRING VALUE
txttot.Text = Val(txtFnum.Text) * Val(txtSnum.Text)
End Sub
[/vbnet] And then, these are the formula for the Divide, Add and Subtract Buttons.
[vbnet] ‘THIS IS FOR DIVISION
Private Sub btndiv_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndiv.Click
txttot.Text = Val(txtFnum.Text) / Val(txtSnum.Text)
End Sub
Private Sub btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadd.Click
txttot.Text = Val(txtFnum.Text) + Val(txtSnum.Text)
End Sub
‘THIS IS FOR SUBTRATION
Private Sub btnsub_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsub.Click
txttot.Text = Val(txtFnum.Text) – Val(txtSnum.Text)
End Sub
[/vbnet] 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.
[vbnet] Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
txttot.Enabled = False
End Sub
[/vbnet] Finally, these are the full codes that you have made.
[vbnet] Public Class Form1
‘THIS IS FOR MULTIPLICATION
Private Sub btnmul_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnmul.Click
‘SET THE VAL TO RETURN A NUMERIC VALUE THAT CONTAINS A NUMBER IN A STRING VALUE
txttot.Text = Val(txtFnum.Text) * Val(txtSnum.Text)
End Sub
‘THIS IS FOR DIVISION
Private Sub btndiv_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndiv.Click
txttot.Text = Val(txtFnum.Text) / Val(txtSnum.Text)
End Sub
Private Sub btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadd.Click
txttot.Text = Val(txtFnum.Text) + Val(txtSnum.Text)
End Sub
‘THIS IS FOR SUBTRATION
Private Sub btnsub_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnsub.Click
txttot.Text = Val(txtFnum.Text) – Val(txtSnum.Text)
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
txttot.Enabled = False
End Sub
End Class