OberonPlace.com Forums  

Go Back   OberonPlace.com Forums > Developer Forums > VBA > CorelDRAW/Corel DESIGNER VBA

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 27-11-2008, 11:12
bprice's Avatar
bprice bprice is offline
Member
 
Join Date: Oct 2006
Location: Edmundston, New Brunswick, Canada
Posts: 89
Default add command button incrementally

i've got this example code from the VB help...

Code:
Dim Mycmd As Control
Private Sub CommandButton1_Click()

    Set Mycmd = Controls.Add("Forms.CommandButton.1", CommandButton2, Visible)
    Mycmd.Left = 18
    Mycmd.Top = 10
    Mycmd.Width = 75
    Mycmd.Height = 20
    Mycmd.Caption = "Button 2" '& Mycmd.Name
    
End Sub

Private Sub UserForm_AddControl(ByVal Control As _
    MSForms.Control)
    Label1.Caption = "Control was Added."
End Sub
what would i have to do to make this add a new button and name it 3,4,5 and so on as I click my command button?

B
Reply With Quote
  #2  
Old 05-12-2008, 02:48
shelbym's Avatar
shelbym shelbym is offline
Senior Member
 
Join Date: Nov 2002
Location: Cheyenne, WY
Posts: 1,770
Blog Entries: 10
Send a message via ICQ to shelbym Send a message via AIM to shelbym Send a message via MSN to shelbym Send a message via Yahoo to shelbym
Default Adding Buttons

Your form will need one command button and a label with the caption of "0". Basically I use the label to store how many times you click the button, you could hide the label so you don't see it.
Code:
Private Sub CommandButton1_Click()
    Dim i As Integer
    
    i = CInt(Label1.Caption) 'Get current count

    Set Mycmd = Controls.Add("Forms.CommandButton.1", CommandButton2, Visible)
        Mycmd.Left = 18 + (75 * i)
        Mycmd.Top = 10
        Mycmd.Width = 75
        Mycmd.Height = 20
        Mycmd.Caption = "Button " & i
    
    i = i + 1 'Increase by one
    Label1.Caption = CStr(i)
End Sub
-Shelby
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Execute Menu or Command Button item with VBA? Shaddy CorelDRAW/Corel DESIGNER VBA 3 19-08-2005 13:06
Command Button In PPaint Webster Corel Photo-Paint VBA 2 04-07-2004 23:38
Command Button at runtime Michael Cervantes Corel Photo-Paint VBA 3 22-04-2004 00:59
Button Hernán New product ideas 3 12-03-2004 17:45
Command Button In PPaint Webster CorelDRAW/Corel DESIGNER VBA 2 31-12-1969 18:34


All times are GMT -5. The time now is 05:38.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright © 2011, Oberonplace.com