|
-
May 13th, 2001, 09:47 AM
#1
Thread Starter
Addicted Member
Making your own custom event subs
How can I create a sub that runs when a variable changes value(without having to check the variable all the time)? Kind of like Form_Load or something.
BTW, Thanks for all your help
Member of the anti-gay cross-dressing trans-species wolves alliance.
-
May 13th, 2001, 10:53 AM
#2
transcendental analytic
You can't. You can though emulate it by using property get/let/set statements.
Use  
writing software in C++ is like driving rivets into steel beam with a toothpick.
writing haskell makes your life easier:
reverse (p (6*9)) where p x|x==0=""|True=chr (48+z): p y where (y,z)=divMod x 13
To throw away OOP for low level languages is myopia, to keep OOP is hyperopia. To throw away OOP for a high level language is insight.
-
May 13th, 2001, 06:06 PM
#3
Although, if you are making a game, you should have a continuous loop where you can check it every time.
Z.
-
May 13th, 2001, 06:20 PM
#4
Frenzied Member
Put this in a class module called clsPlayer (it's just an example) :
Code:
Private pHealth As String
Public Property Let Health(ByVal sData As String)
pHealth = sData
'Put here anything else you want to happen when
'you modify the player's health
End Property
Public Property Get Health() As String
Health = Health
'Put here anything else you want to happen when
'you get the player's health
End Property
To use it, just declare it like this where you would declare the variable:
Code:
Dim Player As New clsPlayer
Then, to access it, do it like this:
Code:
Player.Health = 100
Temp = Player.Health
Hope that clears everything
Last edited by Jotaf98; May 13th, 2001 at 06:24 PM.
-
May 13th, 2001, 08:14 PM
#5
Or you could go overboard, and have every Get/Let create an event... 0.o
Z.
-
May 14th, 2001, 09:03 AM
#6
Frenzied Member
Another approach would be to make a function to return the value of the var, and another to set it.
Code:
Dim MyVar As Long
Public Sub SetMyVar(ToWhat As Long)
MyVar = ToWhat
End Sub
Public Function GetMyVar() As Long
GetMyVar = MyVar
End Sub
There, it should be simplier and faster than Property Get/Set, but you would have to use these functions instead of Something = MyVar or MyVar = Something...
Oh, and thanks for replying. I like people that say "Thanks dude that works you're great"
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
|