3/30/12

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 how to do this I'm going to show you how to duplicate a form using a integer


So now you should be quite comfortable with the layout of visual basic, so now all I all want you to do is create a new project and call it "using integers and creating new objects". Then click okay and a new form will display like so.

Now all I want you to do is double click on the form to get the coding screen up and type this code in exactly otherwise it won't work.

I am now going to explain this code to you as simply as possible so you understand it. So first of we have the "For count As Integer = 1 to 1" this will tell the program to duplicate the the count from "1 to 1" I know going from 1 to 1 sounds stupid but it will duplicate the form once, so if you wanted the form duplicated 5 times you would put "For count As Integer = 1 to 5". 

The "=" sign in the snippet of code gives the value of the integer called "count" and its value is to turn one form into two. Next we have the "F = New Form1" F stands for a completely new object and this objects job is to make a new Form1 it's as simple as that. It will make so many Form1's depending on what value is set for the Integer called count.

The rest is just what you expect to come next, and this is naming the form and actually making the new Form(s) show. "F.name = "web explorer - extra window" creates a new object called "F.name" and it's value is the red text after it. You can change this text to what ever you like as your project won't always be a web explorer. 

Now here is the next part F is now a programmed object and F's value is a new Form1 so now to name the new Form1 we put "F.text = F.name" the text part referring to the letters on the top left hand corner of the form, And this text's value is the same at the past object we made called "F.name" which it's value is "web explorer - extra window" All we need now is to make the form show and that is simply to make the Object "F" which is a new form1 show and this is done using "F.show()"

Now you don't necessarily need to know a lot about "Next" all this does is to tell the scrip to read onto the next command in the overall coding of the program. "End sub" tells the program to that you have finished writing this part of your program. 

Thank you for reading this tutorial and if you have any questions or requests then please contact me. Stay tuned for more amazing visual basic tutorials and lessons.

SHARE THIS POST:

Related Posts:

  • 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
  • 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
  • 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
  • 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
  • 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

0 comments:

Post a Comment