Solved

Using Twips

Posted on 2000-04-29
9
202 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

 
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
 
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…

737 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