Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Dynamically names controls

0 views
Skip to first unread message

Pete Morris

unread,
Oct 30, 2007, 7:03:13 PM10/30/07
to
question about VB 2005 express .

is it possible to refer to controls dynamically?

I mean instead of referring to [ textbox1.text] can I have a

mystring = "textbox1"

then refer to the control named in mystring?

Is that possible? What's the syntax for it?

specifically, I have textboxes named book_1 to book_9
I want to have a loop where I refer to properties of the
textbox named "book_" + str(loop_count)

how do I do that?


Mike Williams

unread,
Oct 31, 2007, 5:10:19 AM10/31/07
to
On 30 Oct, 23:03, "Pete Morris" <nospam.ple@se> wrote:

> question about VB 2005 express .
> is it possible to refer to controls
> dynamically? I mean instead of
> referring to [ textbox1.text] can I
> have a mystring = "textbox1" then

> refer to the control named in mystring.
> Is that possible?

You could upgrade to Visual Basic 6, which has Control arrays
specifically for such purposes. If you don't wish to do that then you
might like to post your question to a dotnet newsgroup. Dotnet (which
is what you are using) is not the same as real Visual Basic and it
does not have Control arrays, but I'm sure it will have some way of
simulating them.

Mike


Steve Gerrard

unread,
Oct 31, 2007, 11:42:50 AM10/31/07
to

"Mike Williams" <gaga...@yahoo.co.uk> wrote in message
news:1193821819.0...@19g2000hsx.googlegroups.com...

Like make your own collection of them, as you can with anything, and then
retrieve them by their key, in this case the name.


0 new messages