Solved

arrow buttons

Posted on 1998-09-17
11
246 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

863 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

Need Help in Real-Time?

Connect with top rated Experts

26 Experts available now in Live!

Get 1:1 Help Now