It isn't clear from your posting which part you need help with.

Connecting to a button?
Programmatically creating a button?
Input of the command?
Associating the command with a button?

Cheers,
_