Visual Basic Creating a simple Calculator to get familiar with the interface and code
- Once you have installed Visual Studio from https://www.visualstudio.com/downloads/, start a new project.
|3.||Select ‘Windows Forms Application’ from Visual Basic Tab. You can rename it here if you need to.|
- Click on the ‘Toolbox’ tab on the left. The toolbar has ‘auto-hide’ option enabled by default. To disable this option, click the small symbol between the ‘down arrow’ symbol and the ‘x’ symbol, on the top-right corner of Toolbox window.
- Get yourself familiar with the tools provided in the box. I have made a calculator interface by using buttons and a Textbox.
- Click on the Properties tab (It is on the right side of the editor). You can change the Text property of a button, and the textbox to rename them. Font property can be used to alter the font of the controls.
- To write the specific action for an event(eg. clicking on a button), double click on the control. Code window will open.
- VB.Net is a powerful language designed for fast development. High encapsulation and abstraction is cost for it. You do not need to add semicolon to indicate the end of a statement, there are no brackets, and most of the time, it auto-corrects the case of the alphabets.
- Code provided in the picture should be simple to understand. Dim is the keyword used to initialize a variable, and new allocates memory. Anything you type in the textbox is of type string by default. Casting is required to use the value as a diﬀerent type.
Enjoy your first creation in VB.Net!