Solved

Using Twips

Posted on 2000-04-29
9
197 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
Comment Utility
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
Comment Utility
Oops. That's not what you wanted. Sorry for misunderstanding.
0
 
LVL 9

Expert Comment

by:Ruchi
Comment Utility
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
Comment Utility
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
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 6

Expert Comment

by:Marine
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
Hey friends thanks,

jairo
0
 
LVL 6

Expert Comment

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

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

763 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

6 Experts available now in Live!

Get 1:1 Help Now