GetKeyboardState copies the status of the 256 virtual keys to the specified buffer.

SetKeyboardState copies a 256-byte array of keyboard key states into the calling thread’s keyboard-input state table.

Code:
    Private Declare Function apiGetKeyboardState Lib "user32" Alias "GetKeyboardState" (ByVal vKeys() As Byte) As Int32
    Private Declare Function apiSetKeyboardState Lib "user32" Alias "SetKeyboardState" (ByVal vKeys() As Byte) As Int32
    Private VK(255) As Byte
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        apiGetKeyboardState(VK) 'Get status of all 256 virtual keys
        MessageBox.Show(VK(20)) 'Show the status of the capslock key
    End Sub
    Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
        VK(20) = 1 'Set status of the capslock key
        apiSetKeyboardState(VK) 'Set status of all 256 virtual keys
        MessageBox.Show(VK(20)) 'Show the status of the capslock key
    End Sub
This is tricky because they seem to need to be passed ByVal, although it should be ByRef.
Does anyone know why this is backwards from normal?