Click to See Complete Forum and Search --> : Instantiating Intrinsic controls


vamsi
March 20th, 2001, 10:07 AM
Hi,
In my program I have two screens. Screen1 has input box which accepts a numberic value. Screen2 has to display the text boxes based on the input given in the Screen1. For example, if user inputs five in the input box of Screen1, the Screen2 should display five text boxes.

Thanks in advance,
Vamsi

John G Duffy
March 20th, 2001, 10:14 AM
Here is a sample of creating controls at run time.
Start a new project, Paste this code into the General declarations section of the form. Run it.
You will see a clickable button on the form

option Explicit

' Declare object variable as CommandButton.
private withevents cmdObject as CommandButton

private Sub Form_Load()
set cmdObject = frmCreate.Controls.Add("VB.CommandButton", "cmdOne")
cmdObject.Visible = true
cmdObject.Caption = "Dynamic Command Button"
cmdObject.Move 1000, 1000, 1000, 1000
End Sub

private Sub cmdObject_Click()
print "This is a dynamically added control"
End Sub

private Sub Form_Unload(Cancel as Integer)
' get rid of created control
me.Controls.Remove cmdObject

End Sub




John G

vamsi
March 20th, 2001, 11:16 AM
Hi John,
Thanks alot for information.

Thanks,
Vamsi