I have a question about using Return True.
I know that sometimes you can use Return True to stop all further processing.
I’m not sure where exactly you can use Return True.
For example, I have a method in the MouseUp event of a canvas after which I would like further processing to stop.
The problem is I am adding a row to a Listbox but I don’t want to have the Change event called right after I add a new row.
Where can you use Return True to stop processing?
you don’t “return true to stop processing” as much as you “return true to indicate that YOU have already handled the situation”
so in this case “returning true” might not be the correct solution, where adding your own flag might be
You can only Return True if the Function returns a Boolean, but if the Method does not return a value, you can just use Return to stop further execution of the method. However, you scenario is a bit different. Returning from the MouseUp event is not going to stop the Change event from firing. What most of us do in that case is to create a Window boolean property (i.e. ProhibitChange).
At the beginning of your Change event put
If not ProhibitChange Then...
//the rest of your code
Then set Prohibit Change = True when you don’t want the event to fire.
Or subclass the Listbox and include a flag or other method in the subclass.
The change event is not raised after a row is added.