0% found this document useful (0 votes)
4 views

calculator vba

The document contains a Visual Basic code snippet for a simple calculator application. It includes various command buttons for performing arithmetic operations such as addition, subtraction, multiplication, and division based on user input. The code also handles input validation and text manipulation for a user interface with a TextBox.

Uploaded by

mayuribhutkar17
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

calculator vba

The document contains a Visual Basic code snippet for a simple calculator application. It includes various command buttons for performing arithmetic operations such as addition, subtraction, multiplication, and division based on user input. The code also handles input validation and text manipulation for a user interface with a TextBox.

Uploaded by

mayuribhutkar17
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Dim no1, no2 As Integer

Dim res As Double Private Sub


CommandButton12_Click()
Dim ch As Integer
TextBox1.Text = ""
End Sub

Private Sub CommandButton1_Click()


Private Sub
TextBox1.Text = Val(TextBox1.Text) &
CommandButton13_Click()
1
ch = 1
End Sub
no1 = Val(TextBox1.Text)
TextBox1.Text = ""
Private Sub
CommandButton10_Click() End Sub
TextBox1.Text = Val(TextBox1.Text)
&0
Private Sub
End Sub CommandButton14_Click()
Private Sub ch = 2
CommandButton11_Click()
no1 = Val(TextBox1.Text)
no2 = Val(TextBox1.Text)
TextBox1.Text = ""
Select Case ch
End Sub
Case 1
res = no1 + no2
Private Sub
TextBox1.Text = res CommandButton15_Click()
Case 2 ch = 3
res = no1 - no2 no1 = Val(TextBox1.Text)
TextBox1.Text = res TextBox1.Text = ""
Case 3 End Sub
res = no1 * no2
TextBox1.Text = res Private Sub
CommandButton16_Click()
Case 4
ch = 4
res = no1 / no2
no1 = Val(TextBox1.Text)
TextBox1.Text = res
TextBox1.Text = ""
End Select
End Sub
End Sub
Private Sub
CommandButton17_Click()
Private Sub CommandButton4_Click()
Dim str As String
TextBox1.Text = Val(TextBox1.Text)
Dim i As Integer &4
End Sub
If TextBox1.Text = "" Then
TextBox1.Text = "" Private Sub CommandButton5_Click()
Else TextBox1.Text = Val(TextBox1.Text)
&5
str = TextBox1.Text
End Sub
i = Len(str)
TextBox1.Text = Mid(str, 1, i -
1) Private Sub CommandButton6_Click()
i=i-1 TextBox1.Text = Val(TextBox1.Text)
&6
End Sub
End If
Private Sub CommandButton7_Click()
End Sub
TextBox1.Text = Val(TextBox1.Text)
Private Sub
&7
CommandButton18_Click()
End Sub
TextBox1.Text = Val(TextBox1.Text)
& "." Private Sub CommandButton8_Click()
End Sub TextBox1.Text = Val(TextBox1.Text)
&8
Private Sub CommandButton2_Click()
End Sub
TextBox1.Text = Val(TextBox1.Text)
&2 Private Sub CommandButton9_Click()
End Sub TextBox1.Text = Val(TextBox1.Text)
&9
Private Sub CommandButton3_Click()
End Sub
TextBox1.Text = Val(TextBox1.Text)
&3
End Sub

You might also like