Results 1 to 6 of 6

Thread: Making your own custom event subs

  1. #1

    Thread Starter
    Addicted Member Cuallito's Avatar
    Join Date
    Apr 2001
    Location
    You know that chest that you could never get opened? If you ever do, I'm there.
    Posts
    136

    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.

  2. #2
    transcendental analytic kedaman's Avatar
    Join Date
    Mar 2000
    Location
    0x002F2EA8
    Posts
    7,221
    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.

  3. #3
    Zaei
    Guest
    Although, if you are making a game, you should have a continuous loop where you can check it every time.

    Z.

  4. #4
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    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.
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

  5. #5
    Zaei
    Guest
    Or you could go overboard, and have every Get/Let create an event... 0.o

    Z.

  6. #6
    Frenzied Member Jotaf98's Avatar
    Join Date
    Jun 2000
    Location
    I'm not gonna give you my IP address! Ok... Portugal, South-Western Europe, 3rd rock from the sun (our star is easy to find, a 47 Ursae Majoris in the Milky Way :p )
    Posts
    1,457
    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"
    Code:
    Temp = Me.GetIQ()
    'Error 9: Overflow
    'DON'T PANIC! :eek:

    To learn how to use realistic effects in your games like fire, rain, snow and magic effects, read my article on particles systems here.


    Jotaf's Theories!
    "Cats land on their feet. Toast lands peanut butter side down. A cat with toast strapped to its back will hover above the ground in a state of quantum indecision."

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width