Solved

Using Twips

Posted on 2000-04-29
9
198 Views
Last Modified: 2010-05-02
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
0
Comment
Question by:jcardenas
  • 4
  • 4
9 Comments
 
LVL 9

Expert Comment

by:Ruchi
ID: 2762346
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
0
 
LVL 9

Expert Comment

by:Ruchi
ID: 2762349
Oops. That's not what you wanted. Sorry for misunderstanding.
0
 
LVL 9

Expert Comment

by:Ruchi
ID: 2762358
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
0
 
LVL 6

Accepted Solution

by:
Marine earned 10 total points
ID: 2762403
You can also use Load Statement to create a control array. In design time you can place a 0 into Index of a command button then when you click on the command button in click event you can have this.

It would look something like this.
After you set the Index of first command button to 0
Private Sub Command1_Click(Index As Integer)
Load Command1(1)
Command1(1).Move Command1(0).Left + Command1(0).Width, 900
Command1(1).Visible = True
End Sub
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 6

Expert Comment

by:Marine
ID: 2762406
well just replace the 900 by the whatever value of the top of the first command button like this. command(0).top
0
 
LVL 9

Expert Comment

by:Ruchi
ID: 2762440
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
0
 
LVL 6

Expert Comment

by:Marine
ID: 2762445
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 :(.
0
 

Author Comment

by:jcardenas
ID: 2762653
Hey friends thanks,

jairo
0
 
LVL 6

Expert Comment

by:Marine
ID: 2762668
Um, you should have awarded this points to Ruchi he has helped more. Although, Thanks.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now