Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Click and CheckStateChanged VB6

Tags:

vb6

According to Microsoft: "In Visual Basic 6.0, the Click event is raised when the CheckBox state is changed programmatically. " and this is exactly what i do not want.

I want click event only raise when i click on the checkbox and not when the state is changed.

Any idea how to do it ?

Thank you

like image 377
User1162527 Avatar asked Dec 21 '25 05:12

User1162527


2 Answers

you can set a flag when you are populating the form from code to ignore changes. This can get messy if the code is not organized well.

Form Level:

  Public IgnoreChange As Boolean

Form Load:

  IgnoreChange = False

Event:

  If IgnoreChange Then Exit Sub

Your code:

  frmReference.IgnoreChange = True
  frmReference.Checkbox1.Checked = True
  frmReference.IgnoreChange = False

Code should only respond to user actions

like image 93
Ňɏssa Pøngjǣrdenlarp Avatar answered Dec 24 '25 10:12

Ňɏssa Pøngjǣrdenlarp


Not sure if it's the best way, but one way would be to have a variable called something like IgnoreEvents and set that to true right before changed the state programmatically. Then in the event handler if that variable is true, you just exit the event handler without doing anything.

like image 25
Hans Olsson Avatar answered Dec 24 '25 09:12

Hans Olsson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!