Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create new object in the program

Status
Not open for further replies.

EricsonJ

Programmer
Mar 3, 2002
44
US
I want to create some objects, such as label, command button, etc, in my program. But I cannot find the function to realize this, how should I do?
 
Look at Load statement. Create a control of each type that you want with INDEX=0 so it is a control array. To create
Dim lngNew as Long
lngNew = controlname.Ubound + 1
Load controlname(lngNew)
controlname(lngNew).Left = ....
..... Generate Forms/Controls Resizing/Tabbing Class
Compare Code (Text)
Generate Sort Class in VB or VBScript
 
Thank you very much for the reply.

I have used the method you mentioned in my programming before. I think the shortcoming of this method is that I must declare all types of objects iin my program, whether I use it or not. I am now working on a program like the VB IDE, in which I have almost all the VB controls there. So, I want to know that if there is a way to create the object from the very beginning.

Thank you again.
 
Yes, it's a potential shortcoming. On the other hand, the alternative method - which involves CreateObject - means you miss out on being able to include specific mehtods and events for the newly created object. Swings and roundabouts.
 
Thank you very much.

I decided to use the traditional way, that is, to declare an array first.

Thank you again.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top