본문 바로가기
카테고리 없음

Visual Basic Code Of Simple Calculator

by bamecuvol1971 2021. 1. 21.


This is a simple calculator created using VB .Net

Simple Calculator using Visual basic.NET 11:15 PM Labels: calculator using Visual basic codes, sample application using Visual Basic This is a simple calculator created using VB.Net.


This are the Codes :
  1. I wrote simple calculator with visual basic but when I debug my code, it has problem and dose not run correctly. My code Public Sub general Dim num1 As Long, num2 As Long Dim result As Singl.
  2. A simple scientific calculator perform basic math calculations such as add, subtract, multiply, squareroot, percentage etc and also used for trigonometric calculation such as tangent, square, sine, cosine, absolute value etc. Here is the code snippets to design a simple scientific calculator in Visual Basic. Scientific Calculator.

Public Class frmcalculator
Dim Operand1 As Double
Dim Operand2 As Double
Dim [Operator] As String
Private Sub btn1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn1.Click, btn2.Click, btn3.Click, btn4.Click, btn5.Click, btn6.Click, btn7.Click, btn8.Click, btn9.Click, Button2.Click
txtsource.Text = txtsource.Text & sender.text
End Sub
Private Sub btnclear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click

Visual Basic Code Of Simple Calculator Free

txtsource.Text = '
End Sub
Private Sub btnadd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnadd.Click
Operand1 = Val(txtsource.Text)
txtsource.Text = '
txtsource.Focus()
[Operator] = '+'
End Sub
Private Sub btndecimal_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If InStr(txtsource.Text, '.') > 0 Then
Exit Sub
Else
txtsource.Text = txtsource.Text & '.'Simple
End If
End Sub
Private Sub btnequals_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click
Dim Result As Double
Operand2 = Val(txtsource.Text)Calculator
'If [Operator] = '+' ThenCreate
' Result = Operand1 + Operand2Simple
'ElseIf [Operator] = '-' Then
' Result = Operand1 - Operand2
'ElseIf [Operator] = '/' Then
' Result = Operand1 / Operand2
'ElseIf [Operator] = '*' Then
' Result = Operand1 * Operand2
'End If
Select Case [Operator]
Case '+'
Result = Operand1 + Operand2
MsgBox(Result.ToString('#,###.00'), MsgBoxStyle.Information, 'Result')
txtsource.Text = Result.ToString('#,###.00')
Case '-'
Result = Operand1 - Operand2
MsgBox(Result.ToString('#,###.00'), MsgBoxStyle.Information, 'Result')
txtsource.Text = Result.ToString('#,###.00')
Case '/'
Result = Operand1 / Operand2
MsgBox(Result.ToString('#,###.00'), MsgBoxStyle.Information, 'Result')
txtsource.Text = Result.ToString('#,###.00')
Case '*'
Result = Operand1 * Operand2
MsgBox(Result.ToString('#,###.00'), MsgBoxStyle.Information, 'Result')
txtsource.Text = Result.ToString('#,###.00')
End SelectVisual Basic Code Of Simple Calculator
txtsource.Text = Result.ToString('#,###.00')
End Sub
Private Sub btnminus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnminus.Click
Operand1 = Val(txtsource.Text)
txtsource.Text = '
txtsource.Focus()
[Operator] = '-'
End Sub
Private Sub btnmultiply_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnmultiply.Click
Operand1 = Val(txtsource.Text)
txtsource.Text = '
txtsource.Focus()
[Operator] = '*'
End Sub

Visual Basic Simple Calculator Code


Private Sub btndivide_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btndivide.Click
Operand1 = Val(txtsource.Text)
txtsource.Text = '
txtsource.Focus()
[Operator] = '/'
End Sub
Private Sub btnaddminus_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button9.Click
txtsource.Text = -1 * txtsource.Text
End Sub
Private Sub btnx_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnx.Click
Dim convert As Single

Create Calculator In Visual Basic

If txtsource.Text <> 0 Then
convert = 1 / Val(txtsource.Text)
txtsource.Text = convert
End If
End Sub
Private Sub frmcalculator_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles Me.KeyDown
If e.KeyCode = Keys.Enter Then

Visual Basic Code Of Simple Calculator Online

Call btnequals_Click(sender, e)
End If
End Sub
Private Sub frmcalculator_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub

Calculator Code For Visual Studio


Private Sub GroupBox1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles GroupBox1.Enter

Visual Basic Code For Beginners

End Sub

Calculator In Visual Studio

End Class