How to Create a Simple Calculator in Visual Basic 6. Steps. 1Open Visual Basic 6. Standard EXE Project. Standard EXE projects give you a handful of commands and tools, useful to develop simple as well as semi- complex programs. For a beginner programmer, it is suggested to use a Standard EXE Project. Understand the project screen. In the center of the screen will be a box with a lot of dots. A form is the place where you will add the various elements (command buttons, pictures, text boxes, etc) to your program. The Toolbox contains various pre- defined elements of any program. You can drag and drop these elements onto your form. A Calculator Project in VB NET. So create a new project, call it Calculator, and let's get started. Let's design the form first. To the lower right of the screen is the form layout. This determines where your program will be displayed on the screen once the project is complete and executed. On the mid- right is the properties box which determine the property of any element that is selected in a form. You can change various properties using this. If no element is selected, it displays the properties of the form. On the top- right is the project explorer. It shows the various designs, forms that are included in a project. If any of these boxes are missing, you can add them by clicking on the .
The Visual Basic Programming Language. VB Project 1: Scientific Calculator. We intend to start a series of VB projects so that together we will make this. Our first project is a scientific calculator. Remove any text that appears inside the textbox by changing blanking the . Change the caption of these command buttons to . This textbox will be used to display the result. With this, your design is complete. Intro: Visual Basic Calculator. Our project will be a basic calculator that will teach the logic.It will take you to the coding screen. One by one, click on all the commands (Command. Command. 2, etc) so that the outline coding of them will be visible to you on your coding screen. Declare the variables. To declare. Dim a, b, r as doublea is the value entered in the first textbox, b is the value entered in the second textbox and r is the result. You can any other variables too. Start the coding for the add command (Command. The code will be as follows. Private Sub Command. The code will be as follows. Private Sub Command. The code will be as follows. Private Sub Command. The coding will be as follows. Private Sub Command. Make your project and save it as a . A multipurpose scientific calculator - Code. Project. 2. 5. 2 (3. A calculator handling complex numbers and scientific functions. Introduction. This is a scientific calculator involving many functions such as: Normal arithmetic operations. Functions such as factorial, permutation, combination etc. Scientific functions (sin, cos, sin- 1, cos- 1, sinh, cosh, sinh- 1,etc.). Operations on complex numbers. Storage of values in variables and operations on these variables. Use of abbreviated form of representing values (such as m for milli, M for mega, etc.). Evaluation of simple series. Expressions involving any combination of the above. Concepts used. Recursive parser: The calculator uses a recursive parser for evaluation of expressions. A part of the recursive parser is represented in the diagram below. The parser uses a proper operator precedence. The complete precedence can be known by looking at the code. Advantage of using the parser for expression evaluation. The complexity of procedure required is broken into many parts thus making each part simpler to understand and the overall structure robust. It becomes easier to to change the operator precedence implemented. An alternative approach. We might use a stack to do the expression evaluation. But then, breaking down of the complexity to many procedures is not as straightforward as in the recursive function approach and we might stand to lose the advantages of the recursyve function approach. Some Special Features. Easy- to- use interface. The calculator provides an easy- to- use interface. The expressions can be entered easily using the keyboard or by clicking the buttons using the mouse. For expressions using variables(X,Y,A,B,etc.) and symbols like pi(. Default is the decimal form. To change to fraction form check the option fraction in the toolstrip menu options- > display. Display of evaluated value in polar form. Complex numbers can be viewed either in the default form(a+bi) or in the form r. L. To change to polar form, check the option polar in the toolstrip menu options- > display. Angle measurements in different units. Angle measurements may be in degree, radian, or grade. The selection may be done using the Domain. Up. Down at the top right of the main form. This selection effects the trignometric calculations as well as the measure of amplitude of complex numbers when they are displayed in polar form. The expression in the expression textbox is re- evaluated as soon as a change in the choice in the Domain. Up. Down is made. Memory calculations. Answer memory. Whenever a value appears on the value textbox, it automatically updates Ans memory contents by storing the result. The value can be used in the next expression using the variable Ans at any position of the expression. Ans memory is not updated in case of error in evaluation. Variables. The calculator provides 9 memory varaibles. Values can be stored in these variables and they may be used later in expressions. The values remain stored in the computer in a file even after closing the application and retain the values the next time we run the application. The value stored in variables can be that of real numbers or co mplex numbers. Series. We may evaluate series such as sum of first ten natural numbers, or product of even numbers from 2. How to use. Just run the demo project. To do this, download the file scientific. Run the file scientific. If the answer is lenghty scroll down the textbox to view the complete answer. To store values in variables and use them. Check the mem radio button. We may directly add or subtract to the memory variables. Depending on whether store,add or subtract checkboxes are checked, values are stored to, added to or subtracted from the variables whose buttons are clicked. If none of check boxes on the memory variables- form are checked, a hit on a button in this form inserts corresponding variable to the expression. The memory variables may contain real values or complex values. To evaluate expressions containing trignometric functions. Check the Trignometry radio button. Now, to simply click the button in the trignometry form to get the funcions to the expression. To get the inverse functions to the expression click inv checkbox and then the button of the trignometric function whose inverse is required in the expression. To evaluate expressions containing series. Check the series radio button. Enter the lower value of the variable in the series expression in expression textbox and check Setlow and then I button. Similarly set the high value of the variable in the sries expression. The upper and lower limit of the variable have to be integers and upper limit should be greater than lower limit numerically. Now enter the expression containing the series expression and press = to view the result. For example, to find sum of first ten natural numbers: type 1 - > Setlow - > I; type 1. Sethigh - > I; type . With a further enhancement, we may get rid of this limitation. Android app. Here is an android app that uses the same parser mentioned in this article: Calculator on Google Play. The only difference is that the App implements the same parser in JS and uses Phone. Gap. Website. Here is a website that uses the same parser mentioned in this article: https: //calc. About me. You can visit my webpage to know more about me. License. This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)Share. About the Author. Comments and Discussions. Bos tutorial videonya dong , lewat visual studio c++Source coude cannot be used! It's just forms and disigner! Missing the . resx files! Add the full project to be usefull! C# version? The calculator however is a good example of what you can do with a parser. WM. What about weapons of mass- construction?? Its an Apple Mac. Book Pro. For example, are there any special things you need to be aware of if you are going to build something like this calculator? WM. What about weapons of mass- construction?? Its an Apple Mac. Book Pro. For example, eval. All these functions take an argument by reference in which the result is returned. Each such function implements certain mathematical operations. For example, eval. You need to be aware of precautions to be taken while writing recursive functions and a basic knowledge of recursive functions. Here are some useful links: http: //en.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |