10/12/12

Creating and using String Variables in visual basic

In today's tutorial I am going to be showing you how to declare and use string variables in visual basic 2010. The very basics of what you need to know about string variables are it will store a string of characters with a label name which you can then call upon later on in your programme. This can save you time as it reduces the amount of code you will have to write.

First of I want you to open up visual basic, you should have this already download and know the basic layout out of the program. You then need to set up a new project and call it "learning to use string variables". Once the form designer has opened up you will need to add one text box and one button. Change the text of button one to "clear text". Your form should look like this:


Once you have the form to look like this you will now open the coding screen to control what each component will do in your form. You should have learnt how to open the coding screen in my previous tutorials. Here the code you will need to write once you have written it we will do a run through of what it actually means.


Now that we have the code in I want you to debug the program and check that it works if not please recheck you have written the code in correctly. Now for the rundown, "Dim text as string"  is basically saying to declare the word "text" as a string which is only characters. "text  = textbox1.text" is assigning a value to the newly declared variable called "text" in this case the value is the text in textbox1.text. Next the code erases what was in textbox1.text this is to prove to you that our variable is truly stored. "messagebox.show(text)" is the clever bit. This is where we create a messagebox to display the value of our string variable. 

And there you have it you have now learnt how to declare and use string variables in visual basic. Stay tuned for more tutorials. Also check out my own website here


SHARE THIS POST:

Related Posts:

  • Using integers and creating new object in Visual Basic In today's tutorial I am going to be showing you how to use integer function in visual basic. Now all you need to know about integer is that it tells the program that you are making a completely new action. And to show you … Read More
  • An introduction to using Visual Basic 2010 Visual basic is an IDE that allows you to make a GUI and then make it do what you want writing code in a language called visual basic. Visual Basic has many useful tools such as the ability to add components from… Read More
  • Know your way around visual basic 2010 In this tutorial I will be showing you your way around certain tools and services you will use a lot while you follow these tutorials so first of all you will need to open up your visual basic which you have downloaded f… Read More
  • Creating and using String Variables in visual basic In today's tutorial I am going to be showing you how to declare and use string variables in visual basic 2010. The very basics of what you need to know about string variables are it will store a string of characters with … Read More
  • Using if statements in visual basic 2010 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 wil… Read More

0 comments:

Post a Comment