Solved

arrow buttons

Posted on 1998-09-17
11
248 Views
Last Modified: 2010-04-30
VB5-DBList control - 2 cmdButtons on form - how do I program the 2 cmdButtons to act like the up and down arrow buttons to move through the list in the DBList control.
0
Comment
Question by:dstef
  • 5
  • 4
  • 2
11 Comments
 
LVL 3

Expert Comment

by:a111a111a111
ID: 1435391
Private Sub Form_Load()
    KeyPreview = True
End Sub

Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
    Select Case KeyCode
        Case vbKeyLeft: Label1.Caption = "Left"
        Case vbKeyRight: Label1.Caption = "Right"
        Case vbKeyUp: Label1.Caption = "up"
        Case vbKeyDown: Label1.Caption = "Down"
    End Select
End Sub

0
 

Expert Comment

by:sjrl
ID: 1435392
My understanding of your question is that you want to be able to navigate the DBList using the 2 buttons. I think the following will work.

The VB SendKeys command sends keystrokes to the active window. So providing the DBList is active, sendkeys should work. To achieve this try

Sub cmdUpButton
   DBList.Activate
   SendKeys "{UP}"
End Sub

similarly SendKeys "{DOWN}" for the down button
0
 

Author Comment

by:dstef
ID: 1435393
What should I substitute for Label1 and Caption in solution one? The Up button name is "cmdUP". The caption on this button is "UP".
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
LVL 3

Expert Comment

by:a111a111a111
ID: 1435394
It is just an example.
0
 

Expert Comment

by:sjrl
ID: 1435395
I think that either a111a111a111 or myself has misunderstood the question. The example given by a111a111a111 allows you to detect which keys have been pressed, whereas my example simulates pressing the keys. Which do you want dstef?
0
 

Author Comment

by:dstef
ID: 1435396
I want my cmdUP and cmdDown to simulate the up and down arrows
On the second suggestion (sjrl) the Activate caused an error message. Program didn't recognize this event or method. Did I leave something out?
0
 

Author Comment

by:dstef
ID: 1435397
I was not clear in stating the problem and a1112a111a111 thought that I wanted to determine what key was pressed. Thanks. sjrl is on the right track, but I still need something clarified. Awaiting reponse from him to my comment.
0
 

Author Comment

by:dstef
ID: 1435398
Problem solved. Thanks sjrl. SendKeys was the right answer, only needed to use DBList1.SetFocus instead of Activate. I don't know how to rate this since it is my first use of this service, but thanks again. Good job.
0
 

Accepted Solution

by:
sjrl earned 100 total points
ID: 1435399
I suggested the .Activate to ensure the DBList was the active control and therefore received the keystrokes. I think there is a way to do this, it maybe .SetFocus or something like that.

Hope this helps.

In order to rate my answer you need to have an answer from me. So here's an "answer" for you to rate.


0
 

Expert Comment

by:sjrl
ID: 1435400
My previous response was added before I got your comment (10:56)
I've had a few problems with getting comments out of sync.
Glad Setfocus worked!
0
 

Author Comment

by:dstef
ID: 1435401
Thanks again.
0

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Link a textbox in excel to a cell with more than 255 characters. 5 93
using web browser with BING 40 121
Visual Studio 2005 text editor 10 38
Zip Folders Using Chilkat Routines 1 40
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question