Mouse over effect

C

Chad

Hello, I have two images (img1 and img2) and I want to have img1 visible when
the form opens and when I run the mouse over img1 it changes it to visible =
False and img2 is visible = True. Also when I mouse off the image it changes
back to img1… How is this done? Thanks!
 
A

Andy Hull

Hi Chad

There isn't a mouse over event but you can use the mouse move event.

Place both images in the form.
I'll assume the one you want shown first is named first_image and the other
is second_image. Set the visible property of second_image to No.

Then select first_image, go to the event tab of its property sheet and next
to "On Mouse Move" choose [Event Procedure] then click the 3 dots to the
right and enter code like...

Me.second_image.Visible = True
Me.first_image.Visible = False

So, when the mouse moves over the first image it will disappear and the
second will appear. Now we need to make the first come back when the mouse
moves off. We know the mouse has moved off if the form background receives a
mouse move event so click on the form background and go to the event tab of
its property sheet.
Then, for the "On Mouse Move" event enter code like...

Me.first_image.Visible = True
Me.second_image.Visible = False


Hope this helps

Andy Hull
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top