I am trying to send keys to a control in my form. But I get a NullReferenceException, and I don't know why. The code is about the same basic as it is:
Private Sub Button19_Click(sender As System.Object, e As System.EventArgs) Handles Button19.Click
DateTimePicker2.Focus() 'commenting out this line has no effect
SendKeys.Send("{F4}") 'error thrown on this line
End Sub
An error is reported object reference not set to an instance of an object, but Sendis a general method, so it does not need an instance.
It's strange if I ignore the error, it works fine and F4 is passed to the control. I know that there was a problem with sendkeys and UAC, but I thought it was resolved (I am using 4.0 framework)
source
share