Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8758045
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:26:53+00:00 2026-06-13T14:26:53+00:00

I am new to using Windows API functions in VBA and I can’t find

  • 0

I am new to using Windows API functions in VBA and I can’t find what the keys(0) exactly does/means. It is also not in a bracket/parentheses so I do not understand how it works. Thanks in advance!

Private Declare PtrSafe Function GetKeyboardState Lib "user32" _
(pbKeyState As Byte) As Long

Property Get Value() As Boolean

    Dim keys(0 To 255) As Byte
    GetKeyboardState keys(0) '<< Can someone explain what this is doing?
    Value = keys(VK_NUMLOCK)

End Property
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T14:26:54+00:00Added an answer on June 13, 2026 at 2:26 pm

    I’m assuming that you already know that GetKeyboardState is used to obtain an array of the state of your keys.

    When you pass keys(0) essentially you are providing the memory location of the array to the Win API function. By doing this, your array is passed by reference to the function and the array you pass is filled with the data.

    Here is sample usage copied from the linked page which I’m providing only because it has lots of comments:

    ' Display the key status of the Enter and Backspace keys
    ' Enter's virtual key code = 13; Backspace's virtual key code = 8
    Dim keystat(0 To 255) As Byte ' receives key status information for all keys
    Dim retval As Long ' return value of function
    
    retval = GetKeyboardState(keystat(0)) ' In VB, the array is passed by referencing element #0.
    ' Display info about Enter
    If (keystat(13) And &H01) = &H01 Then Debug.Print "Enter is being pressed."
    If (keystat(13) And &H80) = &H80 Then Debug.Print "Enter is toggled."
    ' Display info about Backspace
    If (keystat(8) And &H01) = &H01 Then Debug.Print "Backspace is being pressed."
    If (keystat(8) And &H80) = &H80 Then Debug.Print "Backspace is toggled.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

new on ruby and using windows xp and rails 3, i want to send
new on rails and using windows for now,, i have web page that user
I'm new to the NDK. (using Windows). I have downloaded cygwin and the NDK.
I want to take advantage of the new features in Windows 7 using C#
I just started developing my brand new windows 8 application last week using mvvm
I've been using ShowDialog() in following way for all my new Windows. SomeGui test
I'm using .NET 4 and the new RegistryKey.FromHandle call so I can take the
I have the Ruby code below, I am using windows API calls and I
When try to create a new API request with the Windows Azure new Bing
I've been playing around with the google maps api through javascript (I'm also new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.