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.



Post a Comment