Wanting to see an actual example of a coded RaiseEvent statement.
E.g. If one wants the keypress in a TextField1 Control to create an event in say a Default PushButton1, simulating PushButton1 KeyDown event, how does the RaiseEvent statement read in the TextField1.Keypress event ?
I understand the TextField1.Keypress event delivers the ASCII decimal value of the key just entered and
having determined it was the key, RaiseEvent … (what?)
you have to create your own subclasses to add event definitions to them
subclass textfield by dragging one from the right hand library all the way to the left navigator
you should end up with a new item in your project (CustomTextField)
right click on CustomTextField and “Add an event handler” - select the KeyDown event from the list
in the Keydown event handler put
if Key = chr(3) or key = chr(13) then
if raiseEvent EnterPressed() then return true
end if
return KeyDown(key)
right click on CustomTextField and “Add an Event DEFINITION”
in the editor that shows (it looks a lot like the method editor) enter
the NAME - KeyDown
parameters - key as string
return type - boolean
right click on CustomTextField and “Add an Event DEFINITION”
in the editor that shows (it looks a lot like the method editor) enter
the NAME - EnterPressed
return type - boolean
Now when you use this new textfield you’ve created on a layout you will have the option to add the “EnterPressed” event
It does not read at all.
You might have missed in the LR that RaiseEvent can only be used in a class that defines this event. If you want to have a class fire an event in another class like you describe a class interface could be one solution where your Textfield subclass calls a method on your connected PushButton subclass which then can use RaiseEvent.
Just like Dave wrote: Your example sounds rather like you want to push your button when your textfield has a certain content. For that, you would just use PushButton1.Push from within your TextField1.TextChange (or Lostfocus) code. Trying to raise the PushButton.Action event would not work, only a pushbutton subclass can do so. Using PushButton.Push will make it fire its Action event automatically.