Solved

Using Twips

Posted on 2000-04-29
9
199 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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

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…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

778 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