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
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
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.commandbu tton", "otxtNew")
With otxtnew
..Visible = True
..Caption = "Duplicate1"
..Width = Command1.Width
..Height = Command1.Height
..Top = Command1.Top + 200
..Left = Command1.Left
End With
End Sub
Private Sub Command1_Click()
Dim otxtnew As CommandButton
Set otxtnew = Controls.Add("VB.commandbu
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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
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 :(.
ASKER
Hey friends thanks,
jairo
jairo
Um, you should have awarded this points to Ruchi he has helped more. Although, Thanks.
Option Explicit
Private Sub Command1_Click()
Command1.Move 720, Top + 200
End Sub