Results 1 to 8 of 8

Thread: Custom Control = Value to be executed twice..?

  1. #1

    Thread Starter
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,675

    Custom Control = Value to be executed twice..?

    Hello,

    Getting a bit of a headache here because having debugged my soft for hours, i realise i get the Value property get executed twice.

    VB Code:
    1. Public Property Get Value() As CheckBoxConstants
    2.      Value = m_Value
    3. End Property
    4.  
    5. Public Property Let Value(ByVal NewValue As CheckBoxConstants)
    6. If Enabled = True Then
    7.        m_Value = NewValue
    8.        Check1.Value = m_Value   'Problem is here ¦ Exec No:1
    9.        RaiseEvent Click              'And here Exec No: 2
    10.         PropertyChanged "Value"
    11. End If
    12.  
    13. End Property

    Basically in order to get the checkbox showing ticked, i do check1.value = m_value and then RaiseEvent and that should be it in theory.
    But this then has RiaseEvent Click followed after it, which triggers the Value property again, resulting in 2 executions.

    I need to figure out a way to do a single execution only.
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



  2. #2
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: Custom Control = Value to be executed twice..?

    Changing Value property of a checkbox raises the checkbox's click event. If you have RaiseEvent Click in checkbox's click event then changing the value of the checkbox raises the click event of the user control.


    Edit
    Simplified what I said.

  3. #3

    Thread Starter
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,675

    Re: Custom Control = Value to be executed twice..?

    Yea thats what its currently doing..

    But i need to find a way so it doesn do this.. i need 1 execution only.
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



  4. #4
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: Custom Control = Value to be executed twice..?

    If you change Check1.Value then you just don't need to have the additional RaiseEvent after Check1.Value line, because changing the Check1.Value does raise the event. So you're knowingly doing it twice when you could just drop the RaiseEvent line from there.

  5. #5

    Thread Starter
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,675

    Re: Custom Control = Value to be executed twice..?

    ok.. i get what you are saying.

    I put the RaiseEvent under the Check1_Click event. Seems to work fine,,BUT

    If i click on the control then it executes the Value Property, then the Check1_Click event all fine...

    However if i do check1.value = 1 or 0 then the Value property fires up but the Check1_Click property doesnt...
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



  6. #6
    Frenzied Member
    Join Date
    Jul 2004
    Posts
    1,202

    Re: Custom Control = Value to be executed twice..?

    what is your software about?
    come back and mark your original post as resoved if your problem is fixed

    Jamie Garland

  7. #7
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: Custom Control = Value to be executed twice..?

    Setting a value for Check1.value will fire Check1.Click just when the value changes, i.e: if Check1.value = 0 and you execute Check1.value = 0, Check1.Click won't fire.

  8. #8

    Thread Starter
    Frenzied Member some1uk03's Avatar
    Join Date
    Jun 2006
    Location
    London, UK
    Posts
    1,675

    Re: Custom Control = Value to be executed twice..?

    what is your software about?
    Cannot reveal any info on it for now!
    ---------------------------------------
    This is what i have now:

    VB Code:
    1. Private Sub Check1_Click()
    2. RaiseEvent Click
    3. End Sub
    4.  
    5. Public Property Get Value() As CheckBoxConstants
    6.      Value = m_Value
    7. End Property
    8.  
    9. Public Property Let Value(ByVal NewValue As CheckBoxConstants)
    10. If Enabled = True Then
    11.        m_Value = NewValue
    12.        Check1.Value = m_Value     'Doesnt fire From here if i do check1.value = 1/0
    13.        PropertyChanged "Value"
    14. End If
    15. End Property
    Last edited by some1uk03; Jan 2nd, 2007 at 08:02 PM.
    _____________________________________________________________________

    ----If this post has helped you. Please take time to Rate it.
    ----If you've solved your problem, then please mark it as RESOLVED from Thread Tools.



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