Last post Aug 19, 2009 01:44 PM by atconway
Aug 19, 2009 11:25 AM|patr0805|LINK
I know I can use a container object so the vb code can create objects like buttons. My problem is that I can't make a random dim name in a loop. how can I just do something like this or create multiple instances dim a = 0 lp:
dim a as label
the problem is that I need a new dim for each object a text file tells my program to make.
Aug 19, 2009 01:44 PM|atconway|LINK
1st off I hope this was a pseudocode joke, using the 'goto' because that is something that should not be used in a .NET language IMO.
As for the question directly, if you want to create multiple new label instances on a page you can reuse the same varibale over and over reinstantiating it properties each time through the loop.
Take a look at the following code:
Dim MyLabel As New Label
For Counter As Integer = 1 To 10
'Set some of the properties of the new label
MyLabel.ID = "MyLabelName" & Counter
MyLabel.Text = "Hello I am Label # " & Counter
'Add the label to aan ASP.NET panel control already on the page named 'Panel1'
Here is another link with more information from Microsoft:
Hope this helps!