Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsVB SyntaxEnterprise DevelopmentDatabase AccessControlsCOMWin APICrystal ReportDeploymentGeneralGeneral 2
Related Topics
VB.NET / ASP.NETMS SQL ServerMS AccessOther Database ProductsMore Topics ...

VB Forum / General / December 2006



Tip: Looking for answers? Try searching our database.

How to modify label.text in a dynamically generated label

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
vbnewbie - 29 Dec 2006 20:10 GMT
I am having problems accessing properties of dynamically generated
objects. Can someone please help?
In a nutshell:
My app creates an equal number of checkboxes and labels that share the
same Tag number.
The checkboxes name is a concatenation of "chkCancel" and a number that
represents the order in which they were created:
chkCancel0 (Tag = 0)
chkCancel1 (Tag = 1)
chkCancel2 (Tag = 2)
etc...

The same goes for the labels

lblLabel0 (Tag = 0)
lblLabel1 (Tag = 1)
lblLabel2 (Tag = 2)
etc...

When the label is created, its text property is given a value
(lblLabel.text = value).

What I want to do, is clear that text property when I click on the
corresponding checkbox.
I want to do it with a common sub, handler, whatever, that will work
for all checkboxes.
My problem is how to acces the label text property of a dynamically
created label.

Pseudo code:

lableTag = sender.tag
if sender.checked=true then
lblLabel(labelTag).text="" (this is the part I have trouble with)

It must be very simple for an experienced programmer, but not to
vbnewbie... and it is driving me nuts!
Thanks
vbnewbie - 29 Dec 2006 20:15 GMT
I forgot to specify this is for Visual Basic 2005.
Bob Butler - 29 Dec 2006 20:19 GMT
> I forgot to specify this is for Visual Basic 2005.

Then you're a dotnetnewbie, not a vbnewbie!

Signature

Reply to the group so all can participate
VB.Net: "Fool me once..."

Mike Williams - 29 Dec 2006 20:40 GMT
> I forgot to specify this is for Visual Basic 2005.

What's that? Whatever it is, it is nothing to do with "real" Visual Basic.
Whoever sold that to you needs a good "talking to"!

Mike
Rick Rothstein (MVP - VB) - 29 Dec 2006 20:17 GMT
Sender? Tag?

Almost everybody in this newsgroup is using VB6 or lower. While you may get
a stray answer to VB.NET (including VB2003, VB2005 and VB Express which have
dropped .NET from their names) questions here, you should ask them in
newsgroups devoted exclusively to .NET programming (the languages are
different enough to warrant separate newsgroup support). Look for newsgroups
with either the word "dotnet" or "vsnet" in their name.

For the microsoft news server, try these newsgroups for Visual Basic .NET
related questions...

  microsoft.public.dotnet.languages.vb
  microsoft.public.dotnet.languages.vb.upgrade
  microsoft.public.dotnet.languages.vb.controls
  microsoft.public.dotnet.languages.vb.data

And these for more general .NET questions

  microsoft.public.dotnet.general
  microsoft.public.vsnet.general

Note: There are many other .NET newgroups (use the first three "fields" from
the last two as templates when searching for them), but the above ones
should get you started.

Rick

>I am having problems accessing properties of dynamically generated
> objects. Can someone please help?
[quoted text clipped - 34 lines]
> vbnewbie... and it is driving me nuts!
> Thanks
Bob Butler - 29 Dec 2006 20:18 GMT
<cut>
> When the label is created, its text property is given a value
> (lblLabel.text = value).

VB Label controls do not have a Text property; you must be using one of the
misnamed dotnet languages

<cut>
> lableTag = sender.tag
> if sender.checked=true then

yep, looks like it....

Signature

try asking in a group with "dotnet" in the name; this group is for VB 6.0
and earlier
VB.Net and VB 200x are Not.VB

vbnewbie - 29 Dec 2006 20:31 GMT
Thanks to all!
dotnetNewbie...
Bob Butler - 29 Dec 2006 20:38 GMT
> Thanks to all!
> dotnetNewbie...

ROTFL
Bob O`Bob - 29 Dec 2006 20:46 GMT
>> Thanks to all!
>> dotnetNewbie...
>
> ROTFL

Sure proves /some/ of em can learn quick.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.