By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,554 Members | 1,146 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,554 IT Pros & Developers. It's quick & easy.

allowing the user to add a command button

P: 1
hello, I am an extreme novice and was wondering if anyone has an answer for me I cant seem to find in any of my books.

what I want to do:

-Allow the user to Name and create his/her own command buttons within the application

My question is what lines of code do you think I would find helpful?

to be more specific:

I have an "OK" button on one form, I want the action of this button to be "create another command button on a ANOTHER form that the user can drag around that performs a totally separte action (which is add some numbers together)

If you need any more specifics post and Ill give more detail, thanks for reading
Nov 12 '06 #1
Share this Question
Share on Google+
2 Replies


100+
P: 267
hi

i know how to create another object on the same form.
try this
note that you can only use it once, or you need to change the commandbutton's name !

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim ctlName As Control
  3. Set ctlName = frmMain.Controls.Add("VB.CommandButton", "Command2", Form1)
  4. With ctlName
  5. .Visible = True
  6. .Caption = "New button"
  7. .Move 400, 400, 1400, 480
  8. End With
  9.  
  10.  
Nov 12 '06 #2

100+
P: 267
hi

i know how to create another object on the same form.
try this
note that you can only use it once, or you need to change the commandbutton's name !

Expand|Select|Wrap|Line Numbers
  1.  
  2. Dim ctlName As Control
  3. Set ctlName = frmMain.Controls.Add("VB.CommandButton", "Command2", Form1)
  4. With ctlName
  5. .Visible = True
  6. .Caption = "New button"
  7. .Move 400, 400, 1400, 480
  8. End With
  9.  
  10.  
hi another thing
if you create a new button, there is no code behind it, so you can't expect any action when pressed.

might be better if you pre-created a non visible button (with code) and make it visible
Nov 13 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.