Vb6 visual basic 6:以其他形式创建对象

Vb6 visual basic 6:以其他形式创建对象,vb6,Vb6,我想在不同的图片中创建一个矩形 例如:代码在testpicture中,但我希望这个rect是在testpicture2中创建的。 请问怎么可能? 非常感谢解决方案 私有子代名词形式() 按ctrl键作为控件 设置frm=新表格1 Set cmdOK = Nothing Set cmdCancel = Nothing Set txtInput = Nothing Set lblDisplay = Nothing 'clear the form For Each ctrl In frm c

我想在不同的图片中创建一个矩形

例如:代码在testpicture中,但我希望这个rect是在testpicture2中创建的。 请问怎么可能? 非常感谢

解决方案

私有子代名词形式() 按ctrl键作为控件 设置frm=新表格1

Set cmdOK = Nothing
Set cmdCancel = Nothing
Set txtInput = Nothing
Set lblDisplay = Nothing

'clear the form
For Each ctrl In frm
    ctrl.Visible = False
Next

Set cmdOK = frm.Controls.Add("VB.CommandButton", "cmdOK")
Set cmdCancel = frm.Controls.Add("VB.CommandButton", "cmdCancel")
Set txtInput = frm.Controls.Add("VB.TextBox", "txtInput")
Set lblDisplay = frm.Controls.Add("VB.Label", "lblDisplay")

With frm
    'Set form's width and height
    .Width = 4000
    .Height = 2500
    .Caption = "Run-Time Generated Form"
End With

'Setup rest of controls 
With lblDisplay
    .Top = 250
    .Left = 250
    .AutoSize = True
    .FontBold = True
    .Caption = IIf(allowNumericOnly, "Enter Your Age:", "Enter Your Last Name:")

End With

With txtInput
    .Top = lblDisplay.Top + lblDisplay.Height + 250
    .Left = 250

    .Height = 295
    If allowNumericOnly Then
        .Width = 500
        .MaxLength = 3
    Else
        .Width = 2500
    End If
End With

With cmdOK
    .Top = txtInput.Top + txtInput.Height + 375
    .Width = 800
    .Left = 1000
    .Height = cmdGenerate(0).Height
    cmdOK.Caption = "&OK"
    .Enabled = False
End With

With cmdCancel
    .Left = cmdOK.Left + cmdOK.Width + 100
    .Top = cmdOK.Top
    .Width = cmdOK.Width
    .Height = cmdOK.Height
    .Caption = "&Cancel"
End With


cmdOK.Visible = True
cmdCancel.Visible = True
lblDisplay.Visible = True
txtInput.Visible = True
frm.Show vbModal
端接头