Image to follow focus

Posted on 2000-03-22
Last Modified: 2010-05-02
Hello all.  I am programming a user app that requires the user to select from several different options and depending on the option selected the form will take shape.  The positioning of the text boxes and labels is such that the form is somewhat confusing to follow.  So what I would like to use is sort of a follow the bouncing ball kind of thing where the user would do simply that follow a ball or pointer from text box to combo and so on as each of the controls gets focus.  I would like the image to appear on the side of the control or label....I figured this is an easy question for most of you, Thanks for the help.......
Question by:johnmhat

Expert Comment

ID: 2645095
A simpler way might be to set the text color of the label for each control as it becomes active.

Put something like this in each control's GotFocus event:

ControlName.ForeColor = vbRed

In the LostFocus event, put this:

ControlName.ForeColor = vbBlack

This helps you deal with problems where there might not be enough room to show some sort of image, yet gives the user the visual feedback to help them see what's going on.

Accepted Solution

Gordonp earned 50 total points
ID: 2645109

First you'll need your image in a picture box.

picIndicator.Picture = LoadPicture(<Filename>)

then in the GotFocus event of each control

Private Sub <A Control>_GotFocus()

   With <A Control>
   picIndicator.Move .left - picIndicator.width,.top
   End With

End Sub

As Each control gets focus, the indicator picture will appear at the left of the control with focus.

You can adjust the .move parameters to make the indicator appear above/below/to the right of the control

Hope this helps

LVL 32

Expert Comment

ID: 2645173
Or use a shape control for the "bouncing ball."
Option Explicit

Private Sub Check1_GotFocus()
End Sub

Private Sub Combo1_GotFocus()
End Sub

Private Sub Command1_GotFocus()
End Sub

Private Sub Form_Load()
    Shape1.Width = 100
End Sub

Private Sub Text1_GotFocus()
End Sub

Sub BounceBall()
    Shape1.Move ActiveControl.Left - Shape1.Width, _
        ActiveControl.Top, 100, ActiveControl.Height
End Sub
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.


Expert Comment

ID: 2645234
Would it not be better to reorganise your form so the progression was more logical, or even to have several forms accessed sequentially.

If your form is laid out in such a manner that it requires help to follow the flow, then change the layout, rather than add "features" to lead a user through it.


Expert Comment

ID: 2645243
I would agree with Gordonp, visit this site for some suggestions:

Expert Comment

ID: 2645246
I had to do something like this once ... I decided to use a label [>>>](but the code should work just fine).

I would make sure all your Textboxes are an array (just chance the index property starting with 0 to however many you have).  What I did was created a label with [>>>] to use as a pointer.  Instead place the imagebox where you would like the image to appear making sure it has the same index as the textbox.

Set all your imagebox visible properties to FALSE.

Use the below code for your Textbox Gotfocus

Private Sub txtDIALOG__GotFocus(Index As Integer)
Dim X as Integer
    For X = 0 To 20 'How many Textbox/Image you have??
        Image1(X).Visible = False
    Next X
    Image1(Index).Visible = True
End Sub

*Whichever textbox has the focus, the appropriate image will appear next to it and all others will turn invisible.

Hope this is useful.  Good Luck!

Author Comment

ID: 2645721
Thanks for the help...I think I will go back and reorganize the form...It is a case of a project that was started about 6mos ago and now I know alot more about the language...But it is always fun to learn new methods, there is so much...Thanks again

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Introduction While answering a recent question ( in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

786 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