|
-
Mar 30th, 2008, 02:09 PM
#1
Thread Starter
PowerPoster
[RESOLVED] about class
i'm building a usercontrol in visual basic 6, but i need to know one thing about class.... for example:
i have these property in usercontrol:
Code:
property get Col() as collision
end property
property let col() as collision
end property
and i have one class Collision:
Code:
dim s as integer
private sub class_initializate
s=100
end sub
public property let left as integer
s=left
end property
public property get Left as integer
left=s
end property
i know that i have some errors, but i don't know every....
in control utilization i wanted something like these:
Code:
usercontrol.col.left
i wanted change and recive the value... can any one help?
thanks
-
Mar 30th, 2008, 03:00 PM
#2
Thread Starter
PowerPoster
Re: about class
[QUOTE=joaquim]i'm building a usercontrol in visual basic 6, but i need to know one thing about class.... for example:
i have these clsCollision class:
Code:
Option Explicit
Dim lngLeft As Long
Dim lngTop As Long
Public Property Get Left() As Long
Left = lngLeft
End Property
Public Property Let Left(ByVal vNewValue As Long)
lngLeft = vNewValue
End Property
Public Property Get Top() As Long
Left = lngTop
End Property
Public Property Let Top(ByVal vNewValue As Long)
lngTop = vNewValue
End Property
and i have these code in usercontrol:
in general declaration i declare de s variable
Code:
Public Property Get Collision() As clsCollision
Collision = s
End Property
Public Property Let Collision(ByVal vNewValue As clsCollision)
vNewValue = s
End Property
but when i test the code:
Code:
Private Sub Form_Load()
Sprite1.Collision.Left = 100
MsgBox Sprite1.Collision.Left
End Sub
the visual basic 6 give me a error and close it.... why?
i'm new in these....
thanks
-
Apr 4th, 2008, 06:37 PM
#3
Thread Starter
PowerPoster
Re: about class
at least can anyone tell me if these is possible?
thanks
-
Apr 20th, 2008, 03:54 PM
#4
Thread Starter
PowerPoster
Re: about class
heres how is possible do submethods.
-building one class(in these case with these name: clsCollisionLimit):
Code:
Option Explicit
Dim lngLeft As Long
Dim lngTop As Long
Public Property Get Left() As Long
Left = lngLeft
End Property
Public Property Let Left(ByVal vNewValue As Long)
lngLeft = vNewValue
End Property
Public Property Get Top() As Long
Left = lngTop
End Property
Public Property Let Top(ByVal vNewValue As Long)
lngTop = vNewValue
End Property
now for be use in usercontrol we must do these:
in declarations section, we must build a variable:
Code:
Dim MyClass As clsCollisionLimit
now in initializate usercontrol event we put these code:
Code:
Set MyClass = New clsCollisionLimit
at last we must build the method for be used to call the submethods:
Code:
Public Property Get CollisionLimit() As clsCollisionLimit
Set CollisionLimit = MyClass
End Property
now for test we can put these code in form load event:
usercontrol.collisionlimit.left=100
msgbox (usercontrol.collisionlimit.left)
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
|