If you just want the event handler to run, you can invoke it directly as in:
TextBox1_TextChanged(Nothing, Nothing)
This assumes the event handler doesn't use its parameters for anything. If it does, pass the TextBox in as the Sender and build a System.EventArgs to pass for the second argument.
If you truly want to raise the event, for example if you don't know what event handlers are attached to it, you have a couple of choices.
Easiest is to change the text. Unfortunately that changes the text (duh!) so if you want the text to remain unchanged you need to change it back, which raises another event. Not a great solution.
A more "correct" solution is to subclass TextBox to make a new control, say MyTextBox. Give it a method that calls the OnTextChanged subroutine. This routine raises the event. (Controls have other OnXxx methods that raise other events but all of them are hidden inside the class so you have to subclass to find them.
Public Class MyTextBox
Inherits TextBox
Public Sub RaiseChangedEvent()
Me.OnTextChanged(Nothing)
End Sub
End Class
Now the main program can call this control's RaiseChangedEvent method. Again you'll need to build a System.EventArgs object if the event handler(s) needs one.
You could probably also send the TextBox some sort of message but I don't know exactly how you would manage that approach.
I hope that helps,
Rod
Rod Stephens, Visual Basic MVP
RodStephens@vb-helper.com
*** New Book ***
"Visual Basic 2008 Programmer's Reference"
Sign up for the free
VB Helper Newsletters at
http://www.vb-helper.com/newsletter.html