Wrox Programmer Forums
|
BOOK: Visual Basic 2005 Programmer's Reference
This is the forum to discuss the Wrox book Visual Basic 2005 Programmer's Reference by Rod Stephens; ISBN: 9780764571985
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Visual Basic 2005 Programmer's Reference section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 19th, 2006, 01:51 AM
Authorized User
 
Join Date: Jan 2006
Posts: 43
Thanks: 1
Thanked 0 Times in 0 Posts
Default Control Arrays

Hi Rod,

Im again!

In my earlier version of vb6, i create controls at runtime using load. And i can identify with thier index. Here in Vb2005 im able to create controls at runtime, but how can i differentiates them. (by name is not suit for me) suggest anything for that works in a loop

my sample code like this
'i create 10 controls of text1 with the index of 0-9 (ofcourse the index is generated automatically)

x=me.tag
say_rev(x)

sub say_rev(x as integer)
    text1(x).backcolor=vbblue
    text1(x).forecolor=vbwhite
end sub
--------------

can u suggest an alternative in vb 2005

thanks in advance

ackid32


 
Old June 19th, 2006, 08:46 AM
Rod Stephens's Avatar
Wrox Author
 
Join Date: Jan 2006
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

You have two basic choices: store information in the control or store information outside of it.

You can put something on the control to identify it. For example, you can set its Name or Tag property. If you need the Tag property for something else, you can use semi-colons or some other delimiter to store multiple values in it. Or you can make an extender provider to add a new property to the controls (although that's more work).

Second, you can store information in some external data structure. For example, you could make a Dictionary and use the control as a key to look up other information such as an index. Or you could store references to the controls in an array and later look through the array until you find the one you want. A bit more awkward but simple.


Rod
RodStephens@vb-helper.com
Author of "Visual Basic 2005 Programmer's Reference"
http://www.vb-helper.com/vb_prog_ref.htm

Sign up for the free VB Helper Newsletters at http://www.vb-helper.com/newsletter.html
 
Old June 23rd, 2006, 02:50 AM
Authorized User
 
Join Date: Jan 2006
Posts: 43
Thanks: 1
Thanked 0 Times in 0 Posts
Default

any exemples pls.

thanks
ackid32

 
Old June 23rd, 2006, 06:12 PM
Rod Stephens's Avatar
Wrox Author
 
Join Date: Jan 2006
Posts: 647
Thanks: 2
Thanked 96 Times in 95 Posts
Default

Try this one:

    http://www.vb-helper.com/howto_net_control_array2.html


Rod
RodStephens@vb-helper.com
Author of "Visual Basic 2005 Programmer's Reference"
http://www.vb-helper.com/vb_prog_ref.htm

Sign up for the free VB Helper Newsletters at http://www.vb-helper.com/newsletter.html





Similar Threads
Thread Thread Starter Forum Replies Last Post
Control Arrays in VBA? Sanchin Excel VBA 3 March 24th, 2008 04:20 PM
control arrays Jayahar General .NET 0 October 3rd, 2005 12:20 PM
How many control arrays can be placed in a form ramk_1978 Beginning VB 6 3 February 21st, 2005 07:57 AM
Multidemmesional Arrays OR arrays gmoney060 Classic ASP Basics 3 November 1st, 2004 03:42 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.