Arithmetic Operations

Program to performs arithmetic operations (+, -, * and  /).
Sol.
1. Start Visual Basic by clicking on the Start Button => All programs => Microsoft visual sutdio 6.0 => Microsoft Visual Basic 6.0
2. Then you can see New project Dialogbox  select standard Exe project then click open button.
3. Now you have a Form Control. Change Form Caption property to “Arithmetic Operations” and Set an Icon to the Form control by using Icon Property ( Click on ---  button and select an icon from C:\Program Files\Microsoft Visual Studio\COMMON\Graphics\Icons\Misc\MISC25.ico  then click Open button).
4. Add following controls to the form control
Sr. No
Control
Properties
Settings
1
Label
Caption
Font
Enter 1st Value
Times New Roman, Bold, 10 pts
2
Label
Caption
Font
Enter 2nd Value
Times New Roman, Bold, 10 pts
3
Label
Caption
Font
Result
Times New Roman, Bold, 10 pts
4
Label
Name
Caption
Font
Result
Blank
Times New Roman, Bold, 10 pts
5
Textbox
Text
Blank
6
Textbox
Text
Blank
7
Textbox
Text
Blank
8
Commandbutton
Name
Caption
Add
Add
9
Commandbutton
Name
Caption
Subtract
Subtract
10
Commandbutton
Name
Caption
Multiply
Multiply
11
Commandbutton
Name
Caption
Division
Division
12
Commandbutton
Name
Caption
Clear
Clear
13
Commandbutton
Name
Caption
Exit
Exit

5. Double click on the Add commandbutton control and write codes in between Add_click () event procedure.
Private Sub Add_Click()
Result.Caption = Val(Text1.Text) + Val(Text2.Text)
End Sub
6. Double click on the Subtract commandbutton control and write codes in between Subtract_click () event procedure.
Private Sub Subtract_Click()
Result.Caption = Val(Text1.Text) - Val(Text2.Text)
End Sub
7. Double click on the Multiply commandbutton control and write codes in between Multiply_click () event procedure.
Private Sub Subtract_Click()
Result.Caption = Val(Text1.Text) * Val(Text2.Text)
End Sub
8. Double click on the Division commandbutton control and write codes in between Division_click () event procedure.
Private Sub Division_Click()
Result.Caption = Val(Text1.Text) / Val(Text2.Text)
End Sub
9. Double click on the Clear commandbutton control and write codes in between Clear_click () event procedure.
Private Sub Clear_Click()
Text1.Text = ""
Text2.Text = ""
result.Caption = ""
End Sub
10. Double click on the Exit commandbutton control and write codes in between Exit_click () event procedure.
Private Sub Exit_Click()
End
End Sub

11. Now Start project using start   button on the standard toolbar or using F5 shortcut key on the keyboard.



12. Enter 1st value and 2nd value then click on any button (Add, Subtract, Multiply, Division) to get the desired result. If you want to clear all text then click on Clear button if you want to exit from the application then click Exit button.

Related Topics:
  1. Message
  2. Security check
  3. Arithmetic operator
  4. Fill Colour
  5. Popup menu
Download Project PDF