# Visual Basic & Mouse Over



## bear (Jan 1, 1999)

Help,
I am needing some help in Mouse Over in Visual Basic 6. I am trying to have either labels or command buttons that are invisible, but when a mouse passes over it, they appear. I am really wanting to have the line control over a label, so when the user passes the mouse over it, the line will appear, then click on the line, with the label under it. 
If anyone can stear me in the right direction, I would greatly appreciate it, and even some code would help. I am totally lost and confused!!!!  

Thanks,

bear


----------



## Het Irv (Sep 30, 2007)

It has been a while since I used VB but have you tried using something like

If MouseMove = true then
lablexyz.visible = true

or something of that nature (I forget what the syntax would be exactly). But, with that if the mouse is not moving but over the control the control would still be hidden.

I hope this gives you some ideas.


----------



## bear (Jan 1, 1999)

_Thanks_ ver much for the idea. I must be in a slump, as I can not get anything to work. I will just have to worry it to death, until it works.


----------



## Mosaic1 (Aug 17, 2001)

In order to have the command button show when the mouse is moved over it, you need to find out where the command button is located on the form. (Get the range for the X and Y coordinates of command1)

Here's a code sample I wrote for you of using the form's MouseMove event.
When the mouse is over the command button, the button is visible. When the mouse is moved away to another location, the command button again disappears.


```
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, _
 X As Single, Y As Single)
Dim A As Single
Dim B As Single
A = Command1.Left + Command1.Width
B = Command1.Top + Command1.Height

 If X > Command1.Left And X < A _
 And Y > Command1.Top And Y < B Then
 Command1.Visible = True
 Else: Command1.Visible = False
 End If

 
End Sub
```
Also, this assumes you have set the command button's visible property to false in the IDE.


----------



## bear (Jan 1, 1999)

Thanks for your reply on the MouseOver routine. That is just what I was looking for. Thanks again

Bear


----------



## Mosaic1 (Aug 17, 2001)

You're welcome. Good luck with your project.


----------

