Comments

Saturday, March 31, 2012

Using if statements in visual basic 2010

Posted by on Saturday, March 31, 2012 Read our previous post

Today I will be showing you how to use the all famous if statements in visual basic 2010, They are fairly easy to use. if statements allow you to create more complex functions for your program so in this tutorial we will be saying that if a textbox says a certain thing then a certain thing will happen. First of all open up visual basic like so.


Now create a new project you should know how to do this if not see the first tutorial on visual basic. Name the new project "if statement tutorial" Now in the new project you will need to put a textbox and two buttons on the form like this.
So as you can see you will need to place the textbox in the centre of the form and the two buttons in the bottom corners of the form. Name the far left button "HELLO" and the far right button "BYE". Now we have the form set up all you need to do now is double click the back form to get the coding screen up. And on the coding screen you will need to type this code in.

There are four if statements used in this application and these are the four bottom codes of the coding lines. The first if statement means that if the textbox we put in earlier says "HELLO" then button1 which is the one that says "HELLO" becomes visible. The second if statement means exactly the same but with button2 which says "BYE" and the textbox has to say BYE. 


This is a short one but its a simple thing to understand stay tuned for more great visual basic tutorials

© 2010 Code 2 Learn