How To

How to Create a Form Object in VB.net

Member
By Mike
User-Submitted Article
(0 Ratings)
VB.net
VB.net

One of the great benefits of working in a .Net environment is the ability to create really anything from an object. Although this particular example is very basic, it will give you an understanding as to how you can create a form and then create an instance of an object of that form. Here is how you do it.

Difficulty: Easy
Instructions

Things You'll Need:

  • VB.net
  1. Step 1

    Open VB.net and create a new VB.net windows application. This also works very similar in C# as well.

  2. Step 2
    Add Button
    Add Button

    Once you have your new VB.net windows application project in front of you, add a button to the form. In this button we are going to put the code so we can create the object of the form and display it. Where you place the button is irrelevant. So put it where ever you want.

  3. Step 3
    Textbox
    Textbox

    Now add a textbox to the form. The textbox is being used as a control to display on the instance of the object so you can see how you can make changes. You can used any control you want, I chose a textbox.

  4. Step 4
    Visible Property
    Visible Property

    Bring up the properties window of the textbox. This click be done by clicking the textbox and pressing the F4 key on your keyboard. Find the "visible" property and set it to "false". We do not want to show this control when we initially run our program.

  5. Step 5
    Click event
    Click event

    Double click on the button to bring up the button's click event.

  6. Step 6
    Code
    Code

    In the click event we declare a variable as a new instance of our form object. Then using our object variable we set the textbox property to true so it will display and the button's visible property to false so we do not see it. See the associated picture with this step for the code. Ehow does not allow code inside the steps.

  7. Step 7

    Run the program by pressing the F5 key on your keyboard.

  8. Step 8
    Final Results
    Final Results

    When you initial form is displayed, click the button to run the underlying code. You will see another form pop up with the button gone and text textbox displayed. Your results should look similar to the associated picture with this step.

Tips & Warnings
  • If you do not hide the button control it will appear on every instance of the form allowing you to click it creating more instances of the form. You can create as many as your computer's memory will allow.

Post a Comment

Post a Comment
  • Have you done this? Click here to let us know.
I Did This

Related Ads

Computers
Alexia Petrakos,

Meet Alexia Petrakos eHow's Computers Expert.

Get Free Computers Newsletters

Copyright © 1999-2009 eHow, Inc. Use of this web site constitutes acceptance of the eHow Terms of Use and Privacy Policy.   en-US

eHow Computers
eHow_eHow Technology and Electronics