I have a form with a number of buttons on it. I want to change the image from flat to Etched when it is pressed. As the same code applies to each button, excpet it's name, I want to set a variable containign the button name, and pass that the another peice of code which contains the actual button down code. So I came up with this: -
Private Sub Button2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
Dim stButtonNo As String
stButtonNo = "Button2"
Private Sub ButtonDown()
' Special Effect 3 shows effect of Etched
' If you copy the code to another image then change the Image name in the line below
stButtonNo.SpecialEffect = 3
And yes I know I've nicked the basic code from elsewhere.
The problem is, when I click on the button, I get the error "Run time error '424' Object required, and the Debug points to the 'stButtonNo.SpecialEffect = 3' code.
If you go to the vb help on the SpecialEffect Property, and click the Applies To blue words at the top, you will see that this property does not apply to command buttons.
But if you were to do this to, say a text box, here's some code that kinda gets at what you want. It's for a form called Form1, with a text box called TxtBox1 who's special effect is changed bewtween two settings with the On Click Event of two buttons (Command0 and Command1).
The original code is not mine. It was posted by one of our contributers but I can't remember who. If anyone knows who posted it (or you are the original poster) please let me know and I will credit the source properly.