Tuesday, September 14, 2010

vb6 how to dynamically add controls

vb6 can dynamically add a control without control array:
object.add (progid, name, container)

object: necessary. An object expression, its value is "used" in the list of an object.

progid: necessary. A string that identifies the control. Most of the control progid can see objects through the browser to decide. Progid control by the control of the library and class composition. For example, commandbutton control progid is vb.commandbutton. Progid with the object in the browser not the same as shown in the case, visual basic will display a error message including the correct progid.

name: necessary. A string used to identify the members of the collection.

container: Optional. An object reference that specifies the control container. If not specified or null, the default value of controls set their containers. By specifying the parameters, a control can be placed in any existing container control (such as frame control). Users can control or activex document as a container.

For example: (add in picture1 above a commandbutton)
private sub form_load ()
form1.controls.add "vb.commandbutton", "cmdok", picture1
with form1! cmdok
. Visible = true
. Width = 500
. Caption = "confirm (& y)"
end with
end sub

Focus: When you add a reference to the need not permit the control to an existing (already deployed good) application, before using the add method to add the controls you have to have the license keyword.

Add no reference in the run-time control
You can also add methods to dynamically add a reference in the project was not the control. ("Not cited" control is not present in the control toolbox). To do this, you must also add keywords to control the license to the licenses collection. The following example be added before adding the control itself, the control of the permit keyword:
option explicit
private withevents extctl as vbcontrolextender

private sub form_load ()
licenses.add "prjweeks.weeksctl", "xydsfasfjewfe"
set extctl = form1.controls.add ("prjweeks.weeksctl", "ctl1")
extctl.visible = true 'the control is invisible by default.
end sub
However, no reference to such a control program of events, you must use withevents keyword to declare a variable as vbcontrolextender target object (as above), and set the object variable to add a reference to the method returns. Then, vbcontrolextender object objectevent events programming the control of the event. Here is a simple example:
option explicit
dim withevents objext as vbcontrolextender 'statement extender variable

private sub loadcontrol ()
licenses.add "project1.control1", "xydsfasfjewfe"
set objext = controls.add ("project1.control1", "myctl")
objext.visible = true
end sub

private sub extobj_objectevent (info as eventinfo)
'Using the select case programming control events.
select case info.name
case "click"
'Click here to deal with the incident.
'Now show the other case
case else 'unknown event
'Here to deal with unknown events.
end select
end sub

Note: not to an inherent control variables assigned to the vbcontrolextender; any such attempt will cause a type mismatch error.

However, you can also use an object variable declared withevents keyword, and set the method returns a reference to the variable, add the control to a dynamic program of events, as shown below.
option explicit
'Declare an object variable commandbutton.
private withevents cmdobject as commandbutton

private sub form_load ()
set cmdobject = form1.controls.add ("vb.commandbutton", "cmdone")
cmdobject.visible = true
cmdobject.caption = "dynamic commandbutton"
end sub

private sub cmdobject_click ()
print "this is a dynamically added control"
end sub

If you want to add a user control or any activex control to your form, or to the control must be added to the "tool box", or to control the license tags to the licenses collection. For more information, please refer to the "increasing method (licenses set)."

Note: If you add an activex or user control to your project, but did not use it in the form, you must not select "Project Properties" dialog box "build" tab on the "delete the unused The activex control "option. If your application tries to add the control, then the add method will fail because the necessary information has been discarded.

Remove the control

To remove dynamically add controls, use the "remove" method. Please note that you can only remove those who use the "Add" method to add the control (and use the "load" statement to add the control to compare) the following example to delete a dynamic added controls:
form1.controls.remove "ctl1" 'The name of the control ctl1

Recommended links:

Worms and Trojans often stationed where?

News ABOUT Hobby

Corel TEXTURE probe density (b)

Alibaba denies rumors of financial strand breaks from Baidu

realplayer H.264

MY favorite Graphic

Flv to mpeg converter free

U.S. stocks comment: Sun continued blood loss

CFO Carol Yu, Sohu shares the profits leaving nearly 10 million U.S. dollars

On-site supervision Evaluation [3]

Open-source Framework For Thinking About [3]

how to convert M4a to m4r

Easy Games Arcade

Photoshop combat KPT7 (1)

video File converter


  1. Howdy! This is kind of off topic but I need some advice from an established blog.
    Is it difficult to set up your own blog? I'm not very techincal but I can figure things out pretty fast. I'm thinking about creating
    my own but I'm not sure where to begin. Do you have any points or suggestions? With thanks
    Visit my site ; svetol canada

  2. I truly love your blog.. Very nice colors & theme. Did you build this
    amazing site yourself? Please reply back as I'm looking to create my own personal site and would love to find out where you got this from or what the theme is named. Appreciate it!
    My page ; writing fast

  3. This is my first time pay a quick visit at here and i am
    actually pleassant to read everthing at alone place.
    my web page :: Buy Facebook Likes Cheap

  4. Wonderful work! This is the kind of information that are supposed
    to be shared across the web. Disgrace on Google for no longer positioning this
    publish upper! Come on over and visit my web site . Thanks =)
    Here is my blog post : ads

  5. For latest information you have to go to see world wide
    web and on web I found this web site as a finest site for newest updates.
    my webpage - lanautica.com

  6. Exceptional post however I was wanting to know if
    you could write a litte more on this subject?
    I'd be very grateful if you could elaborate a little bit more. Kudos!
    My web page: lanautica.com

  7. I'd like to find out more? I'd love to find out some
    additional information.
    my page: Interior Design Ideas

  8. Great site you have here.. It's hard to find high-quality writing like yours nowadays. I truly appreciate people like you! Take care!!
    Look at my webpage : top friv games

  9. I have to thank you for the efforts you've put in writing this blog. I'm hoping to
    check out the same high-grade blog posts from
    you later on as well. In fact, your creative writing abilities
    has motivated me to get my very own blog now ;)
    Here is my web blog ... wedding insurance reviews

  10. Hello there, You have done an incredible job. I will certainly digg it and personally recommend
    to my friends. I'm sure they will be benefited from this site.
    My web page - adding fractions with unlike denominators

  11. Superb site you have here but I was wanting to know if you knew of any user discussion forums that cover the same topics
    talked about here? I'd really love to be a part of community where I can get responses from other knowledgeable people that share the same interest. If you have any recommendations, please let me know. Thank you!
    Feel free to surf my web site : Above Ground Pools Wood

  12. Heуa i'm for the first time here. I came across this board and I find It truly useful & it helped me out a lot. I hope to give something back and aid others like you helped me.
    Here is my web site ; hotmail iniciar sesion

  13. With havin so much content do you ever run into any problems of plagorism or copyright violation?

    My site has a lot of completely unique content I've either authored myself or outsourced but it looks like a lot of it is popping it up all over the web without my agreement. Do you know any techniques to help prevent content from being stolen? I'd definitely
    appreciate it.
    Here is my site ... http://fans.lavozdigital.es

  14. Hello, I log on to your blogs daily. Your writing style is awesome, keep it up!
    Feel free to surf my homepage : active x bars

  15. Spot on with this write-up, I really believe this amazing site needs far more attention.

    I'll probably be back again to read more, thanks for the information!
    My web page - abraham lincoln speeches

  16. You made some good points there. I looked on the internet for more information about the issue and found most people will go along with your views on this
    Also visit my web blog - http://www.examiner.com/

  17. Yes! Finally someone writes about hack a hotmail email account.
    my web site - Accessory Jordyn taylor

  18. I always emailed this website post page to all my friends,
    because if like to read it after that my contacts will too.

    Here is my web page :: adoption poems and quotes

  19. Good day very nice blog!! Guy .. Beautiful .. Wonderful .

    . I will bookmark your web site and take the feeds additionally?
    I am satisfied to search out numerous useful information
    here in the put up, we'd like develop more strategies on this regard, thank you for sharing. . . . . .

    my blog - Acai Berry Juice Antioxidants

  20. Hi there, I found your web site via Google whilst searching
    for a comparable topic, your web site came up, it
    seems great. I've bookmarked it in my google bookmarks.
    Hello there, just turned into aware of your weblog via Google, and found that it is truly informative. I'm gonna be careful for brussels.
    I will be grateful should you proceed this in
    future. Numerous other people can be benefited
    from your writing. Cheers!

    Here is my web-site - address signs for houses
    Also see my web page :: www.kccboston.org

  21. I like the helpful information you provide in your articles.
    I will bookmark your weblog and check again here frequently.
    I'm quite certain I'll learn plenty of new stuff right here!
    Best of luck for the next!

    Also visit my homepage; abc commercials 1991

  22. Unquestionably believe that that you stated. Your favorite justification seemed
    to be on the net the easiest factor to consider of.
    I say to you, I certainly get irked while other people think
    about issues that they just don't recognize about. You managed to hit the nail upon the highest as neatly as defined out the whole thing with no need side-effects , other people can take a signal. Will likely be back to get more. Thank you

    Also visit my web page :: landing page design

  23. Exceptional post however I was wondering if you could write
    a litte more on this subject? I'd be very grateful if you could elaborate a little bit more. Bless you!

    Visit my web page ... squeeze page

  24. Hi, all the tіme i useԁ tо сheck web site pοsts here in the early hours in the breaκ of day, sinсe i lіke to find out
    morе and mοre.

    my wеbpage webs.com

  25. Hi there colleagues, how іs the whоle
    thing, and ωhat you wish foг to say аbout this аrticle,
    in my view іtѕ in fact amazing designеd
    for me.

    Herе is my webpage; crear facebook gratis

  26. It is not my first time to pay a visіt this ωeb ѕite, i am visiting this websіte dailly and
    get nice data fгom hегe eveгyday.

    Stop by mу wеb ѕitе crear facebook gratis

  27. The Cryotherapy could be integrated in Chiropractic service.
    It is the perform of chiropractors to focus on right joint motion and nerve movement.

    Visit my blog flex mini review

  28. Howdy! Do you know if they make any ρlugins to protect against
    hаckerѕ? I'm kinda paranoid about losing everything I've worked hard on.

    Any ѕuggeѕtіonѕ?

    Also visit my blog - abrir cuenta facebook

  29. Fastidious answers in return of this question with firm arguments and telling the whole thing about that.

    My web blog: Http://sexygirlchat.net

  30. Howdy are using Wordpress for your site platform?
    I'm new to the blog world but I'm trying to get started and create my own.
    Do you require any coding expertise to make your own blog?

    Any help would be really appreciated!

    Here is my homepage :: Butina.lt

  31. Undeniably believe that whіch уοu stаteԁ.
    Youг favоrite reason aрpеаred
    to be on the wеb the simplest thing to bе aware of.
    I say to you, I cегtainly get irκed whіle peοple thinκ about worгіes
    that thеy plainly do nоt know about.
    You managеԁ to hit the nail upon
    the tορ аnd also defined out the whole thing
    wіthout hаνіng side-effеcts
    , peoρle сould take a signаl.
    Will likely be baсk to get more. Thanks

    Alsо vіѕіt mу hοmеpagе .
    .. crear facebook gratis

  32. I have to thank you foг the efforts you've put in penning this blog. I really hope to check out the same high-grade blog posts from you in the future as well. In fact, your creative writing abilities has inspired me to get my own blog now ;)

    My web page crear facebook gratis

  33. Keep this going please, great job!

    my web-site - Teen Porn

  34. I rеаd this poѕt completely concerning the сomparison οf hottest and previous
    technologieѕ, it's amazing article.

    Also visit my homepage http://matrixshafts.com/

  35. Hi, I do believe this is a great site. I stumbledupon it ;)
    I may return yet again since i have saved as a favorite
    it. Money and freedom is the greatest way to change,
    may you be rich and continue to guide others.

    Also visit my site http://www.cfnmfever.net/

  36. Hello, yes this post is truly good and I have learned lot of things from it concerning blogging.


    Here is my web site http://hotgirlsexcam.com/

  37. Excellent blog here! Also your site loads up very fast!
    What host are you using? Can I get your affiliate link
    to your host? I wish my web site loaded up as quickly as yours lol

    Feel free to surf to my weblog :: ferdinandop.pixnet.net

  38. Very nice article. I definitely love this website. Stick with it!

    Check out my web page - jnmassage.info

  39. We are a group of volunteers and opening a new scheme in our community.
    Your website provided us with useful information
    to work on. You have performed an impressive process and our whole neighborhood shall be thankful to you.

    Here is my site; Beautiful Butt Fuck For Maya

  40. I am in fact delighted to glance at this blog posts which contains tons of helpful data, thanks for providing
    these kinds of information.

    Stop by my web page ... xvideo [http://mtp.me/groups/is-visiting-tube-porn-an-unbelievable-way-of-passing-time/]

  41. Hi there to all, because I am really eager of reading this web site's post to be updated on a regular basis. It consists of nice information.

    My page: look at free black porn clips hardcore videos

  42. Cet article donne la lumière dans laquelle nous pouvons observer la réalité. Ceci est très gentil et donne des informations en profondeur. Merci pour ce bel article.

  43. We are Professional manufacturer of high quality taps. We offer a collection of more than 10,000 Taps in our www.tapworld.com.au

  44. Find cool kids glasses discounted costs. Save 70% about RX eyeglasses and structures for children together with following day S&H.


  45. Ensuite, vous pouvez robinets vente sur Internet pour voir si elles ont le même, ou un projet similaire avec moins de prix. Seulement une chose que vous robinets cascade être préoccupés que, toutefois, la possibilité de perdre tous vos dép?ts dans l'expédition et de manutention. Ne pas robinetterie baignoire sélectionnez mitigeur douche est vraiment à l'aise dans ce domaine semble bon nécessité. Il contribue non seulement à la robinet LED de salle de bains, il peut s'assurer qu'il est à bien des égards. Bain et douche robinet peut vous co?ter un peu plus que vous voulez passer, mais une fois que vous l'avez, il semble vraiment bon dans la mitigeur douche.

  46. Achat en ligne pour Bricolage un vaste choix de Robinets de bain, Robinets de douche, Systèmes baignoire & douche de plus à prix bas tous les jours.http://www.robinetso.fr/9-robinet-de-douche

  47. When choosing the http://www.faucetsmarket.com/kitchen-faucets-c-22.html pieces and faucets, one should shop around before purchasing a specific Antique brass faucet. There is always a tendency to find something that may sometimes look better or be priced in Bathroom mirror more pleasing way than the purchased one.