How do I trigger a function on a custom event?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Anil Gupte

    How do I trigger a function on a custom event?

    I want a function to execute when a variable changes. How do I that?

    Something like this:

    Dim Paid as Boolean
    AddEvent Paid.ValueChang ed

    Private Sub Paid_ValueChang ed() handles Paid.ValueChang ed
    ' Update a database
    End Sub

    TIA,
    --
    Anil Gupte
    Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving




  • Rory Becker

    #2
    Re: How do I trigger a function on a custom event?

    Hello Anil,
    I want a function to execute when a variable changes. How do I that?
    >
    Something like this:
    >
    Dim Paid as Boolean
    AddEvent Paid.ValueChang ed
    Private Sub Paid_ValueChang ed() handles Paid.ValueChang ed
    ' Update a database
    End Sub
    TIA,
    You need to change Paid into either a property
    -------------------------------------------------------------
    Private mPaid As Boolean
    Public Property Paid() As Boolean
    Get
    Return mPaid
    End Get
    Set(ByVal Value As Boolean)
    mPaid = Value
    call Paid_ValueChang ed()
    End Set
    End Property
    Private Sub Paid_ValueChang ed()
    ' Update a database
    End Sub
    -------------------------------------------------------------

    or a method that accepts a param

    -------------------------------------------------------------
    Public Sub SetPaid(Value as Boolean)
    mPaid = Value
    Call Paid_ValueChang ed
    End Sub
    Private Sub Paid_ValueChang ed()
    ' Update a database
    End Sub
    -------------------------------------------------------------

    --
    Rory


    Comment

    • Anil Gupte

      #3
      Re: How do I trigger a function on a custom event?

      Thanx to both of you - sounds like it will have to be a property. I will
      have to check this out and see if I can get it to work. Otherwise I will be
      back with more questions.

      BTW, I am not sure what you are showing in the ' (*) And, if you want to
      go the whole hog ... section. Do you have an example link that explains
      what that does and why it is better that way?

      Thanx again,
      --
      Anil Gupte
      Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving



      "Anil Gupte" <anil-list@icinema.co mwrote in message
      news:u2sXdqHdIH A.4436@TK2MSFTN GP05.phx.gbl...
      >I want a function to execute when a variable changes. How do I that?
      >
      Something like this:
      >
      Dim Paid as Boolean
      AddEvent Paid.ValueChang ed
      >
      Private Sub Paid_ValueChang ed() handles Paid.ValueChang ed
      ' Update a database
      End Sub
      >
      TIA,
      --
      Anil Gupte
      Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving


      >
      >

      Comment

      • Anil Gupte

        #4
        Re: How do I trigger a function on a custom event?

        I tried your example and even simplified it. I have not finished yet, but
        as far as I can tell there is nothing wrong in this:

        Public Property Paid() As Boolean
        Get
        Return True
        End Get
        Set(ByVal Value As Boolean)
        ' mPaid = Value
        call Paid_ValueChang ed()
        End Set
        End Property
        Private Sub Paid_ValueChang ed()
        ' Update a database
        End Sub

        If <some conditionThen
        Paid = True
        End If

        In other words I don't need mPaid. Am I right?
        --
        Anil Gupte
        Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving



        "Rory Becker" <rorybecker@new sgroup.nospamwr ote in message
        news:2081c0317c 4e8ca42936370e6 4c@news.microso ft.com...
        Hello Anil,
        >
        >I want a function to execute when a variable changes. How do I that?
        >>
        >Something like this:
        >>
        >Dim Paid as Boolean
        >AddEvent Paid.ValueChang ed
        >Private Sub Paid_ValueChang ed() handles Paid.ValueChang ed
        >' Update a database
        >End Sub
        >TIA,
        >
        You need to change Paid into either a
        property -------------------------------------------------------------
        Private mPaid As Boolean
        Public Property Paid() As Boolean
        Get
        Return mPaid
        End Get
        Set(ByVal Value As Boolean)
        mPaid = Value
        call Paid_ValueChang ed()
        End Set
        End Property
        Private Sub Paid_ValueChang ed() ' Update a database
        End Sub
        -------------------------------------------------------------
        >
        or a method that accepts a param
        >
        -------------------------------------------------------------
        Public Sub SetPaid(Value as Boolean)
        mPaid = Value
        Call Paid_ValueChang ed
        End Sub Private Sub Paid_ValueChang ed() ' Update a database
        End Sub
        -------------------------------------------------------------
        >
        --
        Rory
        >
        >

        Comment

        • rowe_newsgroups

          #5
          Re: How do I trigger a function on a custom event?

          On Feb 22, 1:07 pm, "Anil Gupte" <anil-l...@icinema.co mwrote:
          I tried your example and even simplified it. I have not finished yet, but
          as far as I can tell there is nothing wrong in this:
          >
          Public Property Paid() As Boolean
          Get
          Return True
          End Get
          Set(ByVal Value As Boolean)
          ' mPaid = Value
          call Paid_ValueChang ed()
          End Set
          End Property
          Private Sub Paid_ValueChang ed()
          ' Update a database
          End Sub
          >
          If <some conditionThen
          Paid = True
          End If
          >
          In other words I don't need mPaid. Am I right?
          --
          Anil Guptewww.keenin c.netwww.icinem a.com
          >
          "Rory Becker" <rorybec...@new sgroup.nospamwr ote in message
          >
          news:2081c0317c 4e8ca42936370e6 4c@news.microso ft.com...
          >
          Hello Anil,
          >
          I want a function to execute when a variable changes. How do I that?
          >
          Something like this:
          >
          Dim Paid as Boolean
          AddEvent Paid.ValueChang ed
          Private Sub Paid_ValueChang ed() handles Paid.ValueChang ed
          ' Update a database
          End Sub
          TIA,
          >
          You need to change Paid into either a
          property -------------------------------------------------------------
          Private mPaid As Boolean
          Public Property Paid() As Boolean
          Get
          Return mPaid
          End Get
          Set(ByVal Value As Boolean)
          mPaid = Value
          call Paid_ValueChang ed()
          End Set
          End Property
          Private Sub Paid_ValueChang ed() ' Update a database
          End Sub
          -------------------------------------------------------------
          >
          or a method that accepts a param
          >
          -------------------------------------------------------------
          Public Sub SetPaid(Value as Boolean)
          mPaid = Value
          Call Paid_ValueChang ed
          End Sub Private Sub Paid_ValueChang ed() ' Update a database
          End Sub
          -------------------------------------------------------------
          >
          --
          Rory
          Nothing wrong with it, a properties job to get and set a value, it
          doesn't really matter whether it uses a private variable or not. What
          I would recommend is that you don't save the value to a database every
          time the value is set, it seems like it would cause way too much
          network traffic. If you have a certain time you save the entire object
          it might be best to do all the saves there, and just store the
          property value in a variable until that time comes. Also, unless you
          need to reuse the code in "Paid_ValueChan ged()" you could just put
          that code in the actual set block.

          Thanks,

          Seth Rowe

          Comment

          • Rory Becker

            #6
            Re: How do I trigger a function on a custom event?

            Hello Anil,
            I tried your example and even simplified it. I have not finished yet,
            but as far as I can tell there is nothing wrong in this:
            >
            Public Property Paid() As Boolean
            Get
            Return True
            End Get
            Set(ByVal Value As Boolean)
            ' mPaid = Value
            call Paid_ValueChang ed()
            End Set
            End Property
            Private Sub Paid_ValueChang ed()
            ' Update a database
            End Sub
            If <some conditionThen
            Paid = True
            End If
            In other words I don't need mPaid. Am I right?
            Well I'm a little confused why you're always returning true as the value
            of Paid. if this is the case then a WriteOnly property or a set Method might
            suit better.

            Also you're not doing anything with the incoming value when Paid is being
            set.

            Very confusing

            --
            Rory


            Comment

            • Anil Gupte

              #7
              Re: How do I trigger a function on a custom event?

              Sorry that was one of my dumber ideas. You are right the property will
              always retun true and that is not what I want. So I went back to your
              original code. I should have thought about the implications for at least 10
              minutes before posting the message. :-)

              Thanx much.
              --
              Anil Gupte
              Innovate with UsLeading the Way in Advanced Technology Solutions Discover state-of-the-art services in logistics, databases, and AI designed for evolving



              "Rory Becker" <rorybecker@new sgroup.nospamwr ote in message
              news:2081c0317f 1b8ca43a1f16656 9f@news.microso ft.com...
              Hello Anil,
              >
              >I tried your example and even simplified it. I have not finished yet,
              >but as far as I can tell there is nothing wrong in this:
              >>
              >Public Property Paid() As Boolean
              >Get
              >Return True
              >End Get
              >Set(ByVal Value As Boolean)
              >' mPaid = Value
              >call Paid_ValueChang ed()
              >End Set
              >End Property
              >Private Sub Paid_ValueChang ed()
              >' Update a database
              >End Sub
              >If <some conditionThen
              >Paid = True
              >End If
              >In other words I don't need mPaid. Am I right?
              >
              Well I'm a little confused why you're always returning true as the value
              of Paid. if this is the case then a WriteOnly property or a set Method
              might suit better.
              >
              Also you're not doing anything with the incoming value when Paid is being
              set.
              >
              Very confusing
              >
              --
              Rory
              >
              >

              Comment

              Working...