|
-
Feb 28th, 2002, 12:09 AM
#1
Thread Starter
Member
How to Use Classes in VB?
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!
-
Feb 28th, 2002, 04:27 AM
#2
Retired VBF Adm1nistrator
If the class module is called Class1, then ;
VB Code:
Private Sub Form_Load()
Dim x As Class1
Set x = New Class1
End Sub
Microsoft MVP : Visual Developer - Visual Basic [2004-2005]
-
Feb 28th, 2002, 02:21 PM
#3
Thread Starter
Member
-
Feb 28th, 2002, 07:48 PM
#4
Addicted Member
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
"1 4m 4 1337 #4xz0r!'
Janus
-
Mar 4th, 2002, 05:15 PM
#5
Lively Member
when would you need to destory them?
Under what circumstances would you destory a class?
All will fall before the might of the Black Sashi...
-
Mar 4th, 2002, 06:00 PM
#6
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|