CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1

    Is there a getkey function for vb???

    Is there a function that will return the pressed key that i can use in a loop??? I want to find the pressed key or keys while i am in a loop. I dont want to use the built in keyboard functions for controls. Any ideas???


  2. #2
    Join Date
    Dec 1999
    Posts
    74

    Re: Is there a getkey function for vb???

    You could use this, and it will add the keys pressed to text1

    Public Declare Function GetAsyncKeyState Lib "user32" Alias "GetAsyncKeyState" (ByVal vKey As Long) As Integer


    'the code
    On Error Resume Next
    Do: DoEvents
    Dim X As Integer, i As Integer
    For i = 32 To 256
    X = GetAsyncKeyState(i)
    If X = -32767 Then
    text1 = text1 + Chr(i)
    End If
    Next
    X = GetAsyncKeyState(8)
    If X = -32767 Then
    text1 = Mid(text1, 1, Len(text1) - 1)
    End If


  3. #3

    Re: Is there a getkey function for vb???

    really? thanks!


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured