Visual Basic Introduction

Create an  application in Visual Basic  that says "HI". When done, create an application that does calculations of two numbers.

Start / program / Visual Studio / Visual Basic 2010

Choose windows forms application. And then OK.

You will see a panel with a toolbox (all your buttons), a design panel in the middle and a solution explorer on the right. Drag a button from the toolbox onto your form.

To put code inside your button, double click the button. See a coding panel open.

 

Type messagebox.show("HI") on the line after Private sub and before End Sub

Click the green triangle button to run your program.

See the Form window open and then click the button. It will say "Hi".  It is a good first VB progam.

 

Now, Clean it up with a name of the screen and a name of the button.

Click on the design panel so you see the button with the word "button1". On the right, you will see properties. Change the Text property to "Click to Say Hi".

Click on the entire form to rename the form title. Change the text property to Button Worker.

Make the click to say high button larger by dragging its edge and then double click it to get into the code.  Add the title  parameter to the messagebox.show command.

    MessageBox.Show("Hi", "My Message Box")

 

Hit the green triangle to run this again.

Now, Make a calculator.

Drag over 4 buttons. Name each button's text as divide, multiply, subtract, add

Now you need to be able to enter 2 numbers, so drag over 2 text boxes.

Code the buttons: Double click add button to reach the code.  Add a messagebox command that shows the 2 textbox's text value converted to a double and added.

Hit the green button to text when you are done.

 

Code the other 3 buttons the same way:

Test your program.