Link to home
Start Free TrialLog in
Avatar of jcardenas
jcardenas

asked on

Using Twips

Dear experts i need your help to answer the following question:

Suppose you had a command button called Duplicate.  Write code so that when Duplícate is pressed, a new copy of the button appears 200 twips below the bottom of the original.

Thanks,

Jairo Cardenas
Colombia
Avatar of Ruchi
Ruchi

Suppose your command button on the form is at 720, 960. It will move to 720, 1160 when it clicks.

Option Explicit

Private Sub Command1_Click()
Command1.Move 720, Top + 200
End Sub
Oops. That's not what you wanted. Sorry for misunderstanding.
Place a command button on the form.

Private Sub Command1_Click()
Dim otxtnew As CommandButton

Set otxtnew = Controls.Add("VB.commandbutton", "otxtNew")
With otxtnew
..Visible = True
..Caption = "Duplicate1"
..Width = Command1.Width
..Height = Command1.Height
..Top = Command1.Top + 200
..Left = Command1.Left
End With
End Sub
ASKER CERTIFIED SOLUTION
Avatar of Marine
Marine

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
well just replace the 900 by the whatever value of the top of the first command button like this. command(0).top
Correction: It moves below the bottom of the original command button, not next to the original.

Private Sub Command1_Click(Index As Integer)
Load Command1(1)
Command1(1).Move Command1(0).Left, Command1(0).Top + 200
Command1(1).Visible = True
End Sub
Sorry , i placed 900 there because that was the current position of the top then when i realized his is not goign to be there i told to place the top of the button but didn't add anything to it :(.
Avatar of jcardenas

ASKER

Hey friends thanks,

jairo
Um, you should have awarded this points to Ruchi he has helped more. Although, Thanks.