PDA

View Full Version : Change button focus



austenr
02-08-2010, 09:35 AM
I've got three buttons, each button when focus= true shows a different image. What I want to do is when you click button2 then that image appears and I want the image for button 1 to be set to false. The same with the third button. Essentially only show one image at a time depending on what button is selected. Any ideas?

lucas
02-08-2010, 09:44 AM
can we see the workbook or at least the code?

austenr
02-08-2010, 09:54 AM
Steve what I am working on is not Excel. Just VB. Heres the code if anyone is interested.



Private Sub btnAirplane_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAirplane.Click
If btnAirplane.Focus = True Then
PBAirplane.Visible = True
End If
End Sub


Two other buttons are similar.

duluter
02-08-2010, 11:01 AM
I'm not sure I understand correctly, but in your example code, wouldn't "If btnAirplane.Focus = True Then" always evaluate to True? btnAirplane was clicked, and therefore it has the focus.

Do you want different things to happen when the user does rollovers on the buttons vs. when they click the buttons?

lucas
02-08-2010, 11:27 AM
Would something like the following work?

Private Sub btnAirplane_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAirplane.Click
If btnAirplane.Focus = True Then
PBAirplane.Visible = True
image1.visible = False
image2.visible = False
End If
End Sub

austenr
02-08-2010, 11:33 AM
I came up with that Steve while waiting. That works ut was hoping for somethig w/o so many If statements. Select Case maybe? Also to disable all image when the form loads would you put first thing in the class something like



private sub disableall()
pb1.visible = false
pb2.visible = false
pb3.visible = false
end sub

austenr
09-02-2010, 11:57 AM
Cant seem to find this in the forum. If you have a button you created on your worksheet from the forms toolbar, what is the syntax to make it visible/not visible?