0

I'm trying to learn how to add and move objects in VB6 through the code module. SO far i've figured out how to insert an object but have no idea how to change the position.

This is what i have so far:

Option Explicit
Private WithEvents cmdOk As CommandButton


Private Sub cmdOk_Click()
Unload Me
End Sub

Private Sub Form_Load()
Set cmdOk = Form1.Controls.AdD("VB.CommandButton", "CmdOK")
cmdOk.Visible = True
cmdOk.Caption = "OK"
End Sub

3
Contributors
5
Replies
7
Views
7 Years
Discussion Span
Last Post by gendler.max
0

You have two options...

use the...
.Left
.Top
.Width
.Height

Properties or you could use the...

.Move

Method

Good Luck

0
cmdOk.move left,top,width,height
' or
    cmdOk.left=left
    cmdOk.top=top
    cmdOkwidth=width
    cmdOk.height=height

but if you want to move this control in anotehr form or module you must use public

I'm trying to learn how to add and move objects in VB6 through the code module. SO far i've figured out how to insert an object but have no idea how to change the position.

This is what i have so far:

Option Explicit
Private WithEvents cmdOk As CommandButton


Private Sub cmdOk_Click()
Unload Me
End Sub

Private Sub Form_Load()
Set cmdOk = Form1.Controls.AdD("VB.CommandButton", "CmdOK")
cmdOk.Visible = True
cmdOk.Caption = "OK"
End Sub

0

Thanks to both. Another question. what is the best way to center said object.

0
ctrl.left=(form1.scalewidth-ctrl.width)/2
ctrl.top=(form1.scaleheight-ctrl.height)/2
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.