none
Force Keypress

    Question

  • hello, can anyone help, i am trying to invoke(if that is the right term) a keyup control from another sub, i have tried :

    TextUnitSerialNumber_Keyup(Keys.Return, e)

    but this just throws up an error, i know that i could enclose the code from the keyup control in a function and call the function but i didn't want to create more lines of code unessesarily.

    any clues?

    Thanks in advance!!

    Thursday, January 31, 2013 11:58 AM

Answers

All replies

  • I don't understand what you mean by trying to invoke a keyup control in another sub.

    For example if I have a textbox and I have a Handles TextBox1.KeyUp then what are you attempting to do with it? Invoke a keypress to fire it?

    This is an example of invoking a keypress to fire the TextBox1.KeyUp event I suppose.

    Public Class Form1
    
        Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    
        End Sub
    
        Private Sub TextBox1_TextChanged(sender As Object, e As EventArgs) Handles TextBox1.TextChanged
    
        End Sub
    
        Private Sub TextBox1_KeyUp(sender As Object, e As KeyEventArgs) Handles TextBox1.KeyUp
            If e.KeyData Then
                Me.Text = "KeyStroke occured"
            End If
        End Sub
    
        Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
            TextBox1.Focus()
            SendKeys.Send("A")
        End Sub
    End Class


    You've taught me everything I know but not everything you know.


    Thursday, January 31, 2013 12:06 PM
  • TextUnitSerialNumber_Keyup(Me, New KeyEventArgs(Keys.Return))

    • Marked as answer by The Mexican Thursday, January 31, 2013 12:17 PM
    Thursday, January 31, 2013 12:08 PM
  • Thanks alot Crazypennie! I  was close but the cigar goes to you!

    Thanks also to you Mr Monkeyboy, I needed to fire it from multiple functions without waiting for a keypress.

    Thanks again

    The Mexican

    Thursday, January 31, 2013 12:17 PM