object change events

Drstein99

Junior Contributor
Joined
Sep 26, 2003
Messages
283
Location
Audubon, Nj
I want to dim a boolean object in the beginning of the form, as public.

Dim eTest as boolean = false

Now I want to add an event, changed to be executed when I change the state from "true" to "false" and vice-versa. Like this:

private sub eTestChange() handles etest.statechange

end sub

But I know that's not how I do it. How would I create an event that triggers when that memory variable is changed?
 
You can't. Best you could do is do something like this:
Visual Basic:
Dim b As Boolean = False

Private Sub SetBool(state As Boolean)
  b = state

  'do other stuff here, that you would do in the event if such thing existed
End Sub
Then use SetBool(true) or SetBool(false) to set the boolean, rather than simply b = True or b = False.
 
What happens when I change the the value of a scrollbar, like:

scrollbar.value = 2

The "scrollbar.ValueChanged" event is called?

How come that value knows to call a function?
 
The Value member of the scrollbar is a property, from which the event could be raised as well as the internal variable that holds the value that is returned from the property.
The way you could do what you want is using properties, just like the Value value of the scrollbar.
 
Last edited:
Thats EXACTLY what I'm looking for. I looked it up in the help file and (surprisingly), it was useful.

Thank you very much; I didnt know what this type of functionality was called or even how to look it up - but you nailed it!
 
Back
Top