How do I change the background image of a command button in Visual Basic?

I know how to change it during design time. However, for the sake of a picture-matching game, I need to change the picture during runtime. How do I do it?

2009-01-21T05:25:22Z

Also, how do I set it to (None) during execution?

2009-01-21T05:45:03Z

@Vivek S: I am using VB 6.0 and I want to change the picture of a command button during runtime, WHEN the user clicks the button. So, I don't need those long menus for my program, after all.

myak2009-01-21T06:03:34Z

Favorite Answer

There's a Picture property of Button, so in VB6 for button named CommandButton:

CommandButton.Picture = LoadPicture("c:\\picture.bmp")

You need to change your picture path obviously.

To set it to (none), CommandButton.Picture = Nothing

(Edit)
It's also necessary to set Style property to graphics but I suppose you have already done that during design time. If you didn't:

CommandButton.Style = 1 (Image)
CommandButton.Style = 0 (Standard)

koczera2016-10-25T10:34:18Z

To only personalize the introduction of the buttons, less than button homes choose Graphical for type. That way you are able to replace the BG shade upload textual content, and an icon in case you'll like.

Anonymous2009-01-21T05:42:27Z

VB.NET

Right click on Button >> Properties >>BackGround >> Local Resource >> select picture