Do you want to the simple calculation program in visual basic? Yes we know you want because calculator program is one of the main part in visual basic.
How to Create a Simple Calculator program in VB?
To know the simple process how to create a simple calculator program in VB just follow these steps one by one which are showing below.
Step 1: -
- At first open Visual Basic0 application software
- Then click on or select ‘Standard EXE’ icon from New Project dialog box
- Then click on ‘Open’.
Step 2: -
Form Design: -
Select necessary Control Tool from Tool Box and adjust position to ‘Form Window’: -
- Six Label Box
- Six Text Box
- Six Command Box
Step 3: -
Properties Settings: -
- Select ‘Form1’from Form Window and select ‘Caption’ from Properties Window
- Then replace ‘Form1’ to ‘Simple Calculator Project’ from properties window
- Then select ‘Label1 box’ from Form Window and select ‘Caption’ from Properties Window
- Then replace ‘Label1’ to ‘1st Number’ from Properties Window
- Then select ‘Label 2 box’ from Form Window and select ‘Caption’ from Properties Window
- Then replace ‘Label 2’ to ‘2nd Number’ from Properties Window
- Then select ‘Label 3 box’ from Form Window and select ‘Caption’ from Properties Window
- Then replace ‘Label 3’ to ‘Sum’ from Properties Window
- Then select ‘Label 4 box’ from Form Window and select ‘Caption’ from Properties Window
- Then replace ‘Label 4’ to ‘Subtraction’ from Properties Window
- Then select ‘Label 5 box’ from Form Window and select ‘Caption’ from Properties Window
- Then replace ‘Label 5’ to ‘Multiplication’ from Properties Window
- Then select ‘Label 6 box’ from Form Window and select ‘Caption’ from Properties Window
- Then replace ‘Label 6’ to ‘Division’ from Properties Window
- Then select ‘Text1 box’ from Form Window and select ‘Text’ from Properties Window
- Then remove or erase‘Text1’ from Properties Window
- Then select ‘Text2 box’ from Form Window and select ‘Text’ from Properties Window
- Then remove or erase‘Text2’ from Properties Window
- Then select ‘Text3 box’ from Form Window and select ‘Text’ from Properties Window
- Then remove or erase‘Text3’ from Properties Window
- Then select ‘Text4 box’ from Form Window and select ‘Text’ from Properties Window
- Then remove or erase‘Text4’ from Properties Window
- Then select ‘Text5 box’ from Form Window and select ‘Text’ from Properties Window
- Then remove or erase‘Text5’ from Properties Window
- Then select ‘Text6 box’ from Form Window and select ‘Text’ from Properties Window
- Then remove or erase‘Text6’ from Properties Window
- Then select ‘Command1 box’ from Form Window and select ‘Caption’ from Properties Window
- Then replace ‘Command1’ to ‘+’ from Properties Window.
- Then select ‘Command 2 box’ from Form Window and select ‘Caption’ from Properties Window
- Then replace ‘Command 2’ to ‘-’ from Properties Window.
- Then select ‘Command 3 box’ from Form Window and select ‘Caption’ from Properties Window
- Then replace ‘Command 3’ to ‘*’ from Properties Window.
- Then select ‘Command 4 box’ from Form Window and select ‘Caption’ from Properties Window
- Then replace ‘Command 4’ to ‘/’ from Properties Window.
- Then select ‘Command 5 box’ from Form Window and select ‘Caption’ from Properties Window
- Then replace ‘Command 5’ to ‘CLEAR’ from Properties Window.
- Then select ‘Command 6 box’ from Form Window and select ‘Caption’ from Properties Window
- Then replace ‘Command 6’ to ‘Off’ from Properties Window.
Step 4: -
Code Writing:-
- Double click on ‘+ button’ or ‘Command 1 box’
- Then input code to Command 1 code box
Code: - Text3.Text = Val (Text1.Text) + Val (Text2.Text)
- Then double click on ‘- button’ or ‘Command 2 box’
- Then input code to Command 2 code box.
Code: - Text4.Text = Val (Text1.Text) - Val (Text2.Text)
- Then double click on ‘* button’ or ‘Command 3 box’
- Then input code to Command 3 code box.
Code: - Text5.Text = Val (Text1.Text) * Val (Text2.Text)
- Then double click on ‘/ button’ or ‘Command 4 box’
- Then input code to Command 4 code box.
Code: - Text6.Text = Val (Text1.Text) / Val (Text2.Text)
- Then double click on ‘CLEAR button’ or ‘Command 5 box’
- Then input code to Command 5 code box.
Code: - Text1.text = “”
Text2.text = “”
Text3.text = “”
Text4.text = “”
Text5.text = “”
Text6.text = “”
- Then double click on ‘OFF button’ or ‘Command 6 box’
- Then input code to Command 6 code box.
Code: - End
- Then close code box
Step 5: -
Project Save: -
- Click on ‘Save project’ option from File menu
- Then input any name to file name box and click on Save option from Save file as box
- Then input any new name to file name box
- Then click ‘Save’ option.
Step 6: -
Project Run: -
- Press F5 key from keyboard or click on ‘Start’ from ‘Run menu’ for run the project
- Then click on ‘+’ , ‘-’, ‘*’ and ‘/’ for display the result
- Then click on ‘CLEAR Button’ for clear the Text1 to Text6 box.
- Then click on ‘OFF Button’ for the close the result window
This is the simple way to create a simple calculator program in VB. Now you can easily make a simple calculator program.
COMMENTS