Why don't you put the code in a separate method
Private Sub SendSMS() ' do your thing End Sub
and in your button event handler call this method.
Private Sub btnSendSMS_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSendMessage.Click Call SendSMS() End Sub
Now you can call SendSMS() anywhere in your class without doing something scared, for example, by mimicking button presses.
Steven liekens
source share