switching titles during a mouse over event

hi i have 2 command buttons. command1 and command2.

i want it so that when i move the mouse over 1 of them, the 2 buttons switch captions.

for example when command1 says "im smart" and command2 says "im stupid" i want it so that when the user puts the mouse over command1, the 2 buttons switch captions so that the user cant click on "im smart"

how do i do that?
jungle_man10000Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

g_johnsonCommented:
try putting this in the mousemove event for each command button

if command1.caption = "im smart" then
      command1.caption = "im stupid"
      command2.caption = "im smart"
else
     command1.caption = "im smart"
     command2.caption = "im stupid"
endif
0
g_johnsonCommented:
oops  actually you'll need to modify that just a bit
i'll be right back with it
0
g_johnsonCommented:
This code makes it just recognize the mouse move one time each time you pass over a button

Option Explicit
Dim intLastButton As Integer

Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

If intLastButton = 0 Then
    If Command1.Caption = "im smart" Then
          Command1.Caption = "im stupid"
          Command2.Caption = "im smart"
    Else
         Command1.Caption = "im smart"
         Command2.Caption = "im stupid"
    End If
   
    intLastButton = 1
    Command1.SetFocus
End If

End Sub


Private Sub Command2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If intLastButton = 0 Then
    If Command1.Caption = "im smart" Then
          Command1.Caption = "im stupid"
          Command2.Caption = "im smart"
    Else
         Command1.Caption = "im smart"
         Command2.Caption = "im stupid"
    End If
    intLastButton = 2
    Command2.SetFocus
End If

End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    intLastButton = 0
End Sub
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

GrahamSkanRetiredCommented:
Option Explicit
Dim bHoldOff As Boolean

Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim strMyCaption As String
If bHoldOff = False Then
    strMyCaption = Command1.Caption
    Command1.Caption = Command2.Caption
    Command2.Caption = strMyCaption
    bHoldOff = True
End If
End Sub

Private Sub Command2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim strMyCaption As String
    If bHoldOff = False Then
        strMyCaption = Command2.Caption
        Command2.Caption = Command1.Caption
        Command1.Caption = strMyCaption
        bHoldOff = True
    End If
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    bHoldOff = False
End Sub
0
jungle_man10000Author Commented:
wow dat was fast thx

can u tell me how to do teh same thing when people use the tab button
like if the tab focus is on one of the buttons the same thing happens?

lol im trynna make a unwinnable idiot test
0
g_johnsonCommented:
put the same code in the gotfocus event of each button
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.