Hi, I have troubles with using Classes
First I add a Class, then I declare a variable for this class.
And when I start using the functions of this class I get a mistake
Does anybody know how to declare classes properly?
Thanks!
Printable View
Hi, I have troubles with using Classes
First I add a Class, then I declare a variable for this class.
And when I start using the functions of this class I get a mistake
Does anybody know how to declare classes properly?
Thanks!
If the class module is called Class1, then ;
VB Code:
Private Sub Form_Load() Dim x As Class1 Set x = New Class1 End Sub
Thanks, It works!!!!
Here's some info on classes:
They are 'objects', not variables. Objects must be Created before you can use them, and then once you're done, you have to Destroy them. This is done in vb by:
VB Code:
Set MyClass1 = New Class1 ' Create
VB Code:
Set MyClass1 = Nothing ' Destroy
Under what circumstances would you destory a class?
You don't destroy the class. Also you don't create it by declaring it.
What you create and destroy are objects based on the class.
plenderj and janus pointed out how to do this.
You should always destroy the object when you're sure you won't need it ne more to free up memory space.
Helger