How to Create & Delete the Vb6 Object

Creating an object in Visual Basic 6 (VB6) means instantiating a class object and assigning it to a variable. Instantiating a class object means you invoke the class methods and properties, so you can use them in the code. After you finish using the object, you set the variable to "Nothing" to delete it.

Instructions

    • 1

      Click the Windows "Start" button and click "All Programs." Click "Visual Basic," then click "Visual Basic 6" to load the program.

    • 2

      Press the "Ctrl" and "O" keys to open a dialog window. Double-click your VB6 project name to open it in the editor.

    • 3

      Double-click the code file you want to edit. You can create and delete an object anywhere in your code, but you typically create and delete class objects in one of your functions. Scroll down to a function, which is where you type the object code.

    • 4

      Type the following code to create a class object:

      Private myvar As Customers

      Set myvar = new Customers

      The code above instantiates the class object "Customers" and assigns the object to the variable named "myvar."

    • 5

      Delete the object. The following code shows you how to delete the object after you finish using it in your VB6 code:

      myvar = Nothing

Related Searches:

References

Comments

Related Ads

Featured