Professional Documents
Culture Documents
Dot Net Technology Practical
Dot Net Technology Practical
Dot Net Technology Practical
- 22BECE30224
Practical : 1
Aim : Write a program for Arithmetic Calculator using Windows Application.
Steps :
=> Define the Form1 class and declare variables.
=> Each number button (0-9) has an event handler that appends the button's text to the text box. Clarity
updates the display with the clicked number.
=> Each operator button (+, -, x, /) stores the first operand (a) and the operator (op), then clears the
display for the second operand (b) and Each Operand enter then clears the display.
=> Retrieve the second operand, calculate based on the operator, and display the result.
newCalculator.vb :
Public Class frmCalc
Dim a As Integer
Dim b As Integer
Dim op As Char
End Sub
End Sub
End Sub
End Sub
End Sub
End Sub
End Sub
End Sub
End Sub
End Sub
op = btnAdd.Text
a = Convert.ToInt16(txtDisplay.Text)
txtDisplay.Clear()
End Sub
op = btnSub.Text
a = Convert.ToInt16(txtDisplay.Text)
txtDisplay.Clear()
End Sub
op = btnMul.Text
a = Convert.ToInt16(txtDisplay.Text)
txtDisplay.Clear()
End Sub
op = btnDiv.Text
a = Convert.ToInt16(txtDisplay.Text)
txtDisplay.Clear()
End Sub
txtDisplay.Clear()
End Sub
b = Convert.ToInt16(txtDisplay.Text)
ans = a + b
End If
ans = a - b
End If
ans = a * b
End If
ans = a / b
End If
txtDisplay.Text = ans.ToString()
newAns = Convert.ToInt16(txtDisplay.Text)
End Sub
End Class
Output :