How to make a calculator with visual basic

how to make a calculator with visual basic

Visual Basic Calculator

May 01, Step 2: In the properties window, under the Text property, type Simple Calculator. Step 3: In the properties window, under the StartPosition property, select CenterScreen. Step 4: In the properties window, under FormBorderStyle, select Fixed3D. Step 5: Click and drag a label from the Toolbox to the form. Select the CommandButton icon on the toolbar and create the first button the same way you created the TextBox to add buttons. For reference, use the Windows calculator in Standard view (Programs > Accessories > Calculator) as a basis for your calculator layout, .

In this post we will learn to create a simple calculator in Visual basic 6. It is a simple application project to help you learn Visual basic programming. The calculator application does simple arithmetic operations. You can construct an advanced calculator which need same kind of coding that we are going to use in this program, however, the computational logic may differ. The overall steps required to create the Calculator application is as follows. Open your Microsoft Visual basic 6.

Resize the Form for Calculator application appropriately and this can be done changing the width and the height property. Now add buttons and a single text box from Toolbox on the left sidebar of Visual basic editor window. Change the width and the height property of Textbox control, so that it is aligned with the buttons. The original fonts are very small, change the font-size of the buttons to 16px and font-weight to bold.

Only one button in the above figure is of different size which is Command10 because it is for the number 0. Set the width of this button to px. The buttons are not aligned properly both horizontally and vertically. You can align the controls using Format tab of Visual basic editor menu bar.

The buttons get aligned to top. Repeat the step for all rows of buttons. The column gets left aligned. Repeat the same step for each column. The button space becomes equal between the first and the last button of the row. The button space vertically becomes equal between the first and the last button of the column.

Repeat the step for all column of buttons. We follow this convention throughout the post. Next we start naming form controls by putting caption for our button and textbox controls, but before that name the form to frmCALC and set form caption to Calculator. Similarly, change the names and caption of all the other buttons and textbox. For your convenience here is the list of controls and their names, caption values and other properties.

Now the Calculator should appear as in the following figure. Make correction if you did not get it right. To add style and change the appearance of Calculator application, you can do a lot of things in Visual basic 6.

We will change the appearance of Calculator by doing following. Please support us by disabling your adblocker or whitelist this site from your adblocker. Skip to content. Design the interface of the Calculator application. Name the buttons and textbox controls used in the application. Write VB codes for each controls without making any mistakes. Test the Calucator application and make sure it works and there is no error of any kind.

Add style to Calculator by changing the background and color of buttons. This site uses cookies: Find out what is charge off rate.

Our Best Phone Hacks

Nov 12, How to Create Calculator in Visual likedatingus.com Full TutorialTo Become a Channel member click on the Link below to JOIN:likedatingus.com Mar 16, If you're new to the Visual Basic IDE, looking to brush up on your VB programming skills, or simply have a burning desire to code a simple calculator, Author: Robin Mansur.

This article was co-authored by our trained team of editors and researchers who validated it for accuracy and comprehensiveness. The wikiHow Tech Team also followed the article's instructions and verified that they work.

This article has been viewed , times. Learn more This wikiHow teaches you how to use Microsoft's Visual Basic 6. Keep in mind that Visual Basic 6. Log in Social login does not work in incognito and private browsers.

Please log in with your username or email to continue. No account yet? Create an account. Edit this Article. We use cookies to make wikiHow great. By using our site, you agree to our cookie policy. Cookie Settings. Learn why people trust wikiHow.

Download Article Explore this Article parts. Tips and Warnings. Related Articles. Part 1 of Create a new folder for your calculator. To house all of your calculator's necessary files, do the following: Go to the location in which you want to save your VB6 calculator.

Right-click a blank space. Select New in the drop-down menu. Click Folder. Open Visual Basic 6. This will bring up the project selection page. Click Standard EXE. It's in the project selection field. Click Open. This is in the bottom-right corner of the window. Doing so creates a new project. Part 2 of Open the "Text Box" tool. Click the ab button on the left-hand side of the window. Create a text box. Click and drag your mouse down and right to draw an outline of the text box, then release the mouse button when the text box is the proper size.

Ideally, your text box will be significantly longer than it is tall. Copy the text box. Paste in the text box twice. You should see your pasted text boxes appear in the upper-right side of the page. If prompted to create a new control array after pasting in a text box, click No.

Arrange the text boxes in a stack. Click and drag the text box in the top-left side of the page down to the bottom slot, then move the second text box from the top-left side of the page into the middle slot.

You should now have a stack of three text boxes. Remove the text boxes' default text. To do so: Click a text box. Click the text field to the right of the "Text" heading in the "Properties" pane on the right side of the window. Press Delete. Repeat with the other two text boxes. Create three label boxes.

Click the A button in the left-hand toolbar, then do the following: Resize the label box to your preferred size. Select the label box, then copy it. Paste twice the label box. Place the label boxes to the left of the text boxes.

Click and drag each label box to sit to the left of each text box. Edit the top label box's caption. To do so: Click the top label box. Click the text box to the right of the "Caption" heading in the "Properties" pane on the right side of the window. Type in Number 1. Edit the other two label boxes' captions. You'll label them like so: Click the middle label box, then change its caption to Number 2.

Click the bottom label box, then change its caption to Result. Make the label boxes transparent. This isn't necessary, but it will make your calculator more visually appealing: Select a label box. Click the "BackStyle" drop-down box in the "Properties" pane. Click Transparent in the drop-down menu.

Title your calculator. To change the text that appears at the top of the calculator's window when you run it, do the following: Click a blank space on the form. Click the "Caption" header's text box in the "Properties" pane. Type in Simple Calculator or whatever you want to name the calculator.

Part 3 of Click the "Button" tool icon. It's a grey box icon below the ab option in the left-hand toolbar. Create a square button.

Click and drag in a diagonal direction until you see a small square outline appear, then release the mouse button. You should see a grey button display on the form.

Copy the button. Paste the button three times. This will create a total of four buttons on your project. Arrange the buttons below the calculator's input fields. Click and drag each button so that you have a row of them below the "Result" text box. Edit the buttons' captions. Click the next button to the right, then change its "Caption" text to -. Part 4 of Doing so opens a code console. Enter the addition code. Type the following code into the console, directly below the "Private Sub" text and directly above the "End Sub" text.

Return to the calculator form. Double-click the Form1 option under the "Project1" heading on the right side of the page to do so. Double-click the - button. This will re-open the console. Enter the subtraction code. Type the following into the console: Text3. Enter the multiplication code. Enter the division code. Part 5 of Save your project. Select your "Calculator" folder as the save location. Click Save.

How to make a calculator with visual basic: 4 comments

  1. Gasida

    Ave Mcree i tough all daws had this floating point so can avoid distortion and our equipments to like blow up

    Reply

Add a comment

Your email will not be published. Required fields are marked *