473,320 Members | 1,957 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

label control arrays

I know this is probably talk about millions of time here, but I cant seem
to find a close one, I am so used to the vb6 control array, now that I have
to use vb.net for my project, I like to do the following in vb.net with this
vb6 way:

In vb6, I would create five labels array on a form:
lblDisplay(1)...lblDisplay(5), and in each label I would have tag property:
Display1...Display5.

Then, in code (omitted some connection string below):

rst = new ADODB.Recordset
for i = 1 to lblDisplay.Count
rst.open("select Value from Tags where Name='" & lblDisplay(i).Tag &
"'")
lblDisplay(i).Caption = rst!Value
next i
How would I do this in VB.NET? I read some books, they mentioned about
using the Tag property to identify the control, but I want to get your
opinion on this.
Thanks!!!
Nov 21 '05 #1
7 15588
This should get you started:

In the Load event of a form:

Dim LBL(5) As Label
Dim i As Int32
For i = 0 To 5
LBL(i) = New Label()
LBL(i).Top = i * 22
LBL(i).Text = "LBL" & i.ToString
Me.Controls.Add(LBL(i))
Next

You can use a Datatable instead of a Recordset as your data store.

The .Net Label has a Tag property.

www.charlesfarriersoftware.com

"anthony" wrote:
I know this is probably talk about millions of time here, but I cant seem
to find a close one, I am so used to the vb6 control array, now that I have
to use vb.net for my project, I like to do the following in vb.net with this
vb6 way:

In vb6, I would create five labels array on a form:
lblDisplay(1)...lblDisplay(5), and in each label I would have tag property:
Display1...Display5.

Then, in code (omitted some connection string below):

rst = new ADODB.Recordset
for i = 1 to lblDisplay.Count
rst.open("select Value from Tags where Name='" & lblDisplay(i).Tag &
"'")
lblDisplay(i).Caption = rst!Value
next i
How would I do this in VB.NET? I read some books, they mentioned about
using the Tag property to identify the control, but I want to get your
opinion on this.
Thanks!!!

Nov 21 '05 #2
This should get you started:

In the Load event of a form:

Dim LBL(5) As Label
Dim i As Int32
For i = 0 To 5
LBL(i) = New Label()
LBL(i).Top = i * 22
LBL(i).Text = "LBL" & i.ToString
Me.Controls.Add(LBL(i))
Next

You can use a Datatable instead of a Recordset as your data store.

The .Net Label has a Tag property.

www.charlesfarriersoftware.com

"anthony" wrote:
I know this is probably talk about millions of time here, but I cant seem
to find a close one, I am so used to the vb6 control array, now that I have
to use vb.net for my project, I like to do the following in vb.net with this
vb6 way:

In vb6, I would create five labels array on a form:
lblDisplay(1)...lblDisplay(5), and in each label I would have tag property:
Display1...Display5.

Then, in code (omitted some connection string below):

rst = new ADODB.Recordset
for i = 1 to lblDisplay.Count
rst.open("select Value from Tags where Name='" & lblDisplay(i).Tag &
"'")
lblDisplay(i).Caption = rst!Value
next i
How would I do this in VB.NET? I read some books, they mentioned about
using the Tag property to identify the control, but I want to get your
opinion on this.
Thanks!!!

Nov 21 '05 #3
Anthony,

Yes I have answered this often, however it is simple, create yourself that
array of labels and than you can use the code as you do. Using VBNet you can
put any control in an array and mixed exactly as you want.

dim myLblArr() as label = new label() {label1,label2,label3,label5,etc)

As question, is there any reason why you use ADODB, with that you have
forever to deploy as well the DLL, why not ADONET?

I hope this helps?

Cor

"anthony"
I know this is probably talk about millions of time here, but I cant seem
to find a close one, I am so used to the vb6 control array, now that I
have
to use vb.net for my project, I like to do the following in vb.net with
this
vb6 way:

In vb6, I would create five labels array on a form:
lblDisplay(1)...lblDisplay(5), and in each label I would have tag
property:
Display1...Display5.

Then, in code (omitted some connection string below):

rst = new ADODB.Recordset
for i = 1 to lblDisplay.Count
rst.open("select Value from Tags where Name='" & lblDisplay(i).Tag &
"'")
lblDisplay(i).Caption = rst!Value
next i
How would I do this in VB.NET? I read some books, they mentioned about
using the Tag property to identify the control, but I want to get your
opinion on this.
Thanks!!!

Nov 21 '05 #4
Anthony,

Yes I have answered this often, however it is simple, create yourself that
array of labels and than you can use the code as you do. Using VBNet you can
put any control in an array and mixed exactly as you want.

dim myLblArr() as label = new label() {label1,label2,label3,label5,etc)

As question, is there any reason why you use ADODB, with that you have
forever to deploy as well the DLL, why not ADONET?

I hope this helps?

Cor

"anthony"
I know this is probably talk about millions of time here, but I cant seem
to find a close one, I am so used to the vb6 control array, now that I
have
to use vb.net for my project, I like to do the following in vb.net with
this
vb6 way:

In vb6, I would create five labels array on a form:
lblDisplay(1)...lblDisplay(5), and in each label I would have tag
property:
Display1...Display5.

Then, in code (omitted some connection string below):

rst = new ADODB.Recordset
for i = 1 to lblDisplay.Count
rst.open("select Value from Tags where Name='" & lblDisplay(i).Tag &
"'")
lblDisplay(i).Caption = rst!Value
next i
How would I do this in VB.NET? I read some books, they mentioned about
using the Tag property to identify the control, but I want to get your
opinion on this.
Thanks!!!

Nov 21 '05 #5
Thanks for your reply,

It looks like I have to create the label controls in run time.
"Charlie" <Ch*****@discussions.microsoft.com> wrote in message
news:D3**********************************@microsof t.com...
This should get you started:

In the Load event of a form:

Dim LBL(5) As Label
Dim i As Int32
For i = 0 To 5
LBL(i) = New Label()
LBL(i).Top = i * 22
LBL(i).Text = "LBL" & i.ToString
Me.Controls.Add(LBL(i))
Next

You can use a Datatable instead of a Recordset as your data store.

The .Net Label has a Tag property.

www.charlesfarriersoftware.com

"anthony" wrote:
I know this is probably talk about millions of time here, but I cant seem to find a close one, I am so used to the vb6 control array, now that I have to use vb.net for my project, I like to do the following in vb.net with this vb6 way:

In vb6, I would create five labels array on a form:
lblDisplay(1)...lblDisplay(5), and in each label I would have tag property: Display1...Display5.

Then, in code (omitted some connection string below):

rst = new ADODB.Recordset
for i = 1 to lblDisplay.Count
rst.open("select Value from Tags where Name='" & lblDisplay(i).Tag &
"'")
lblDisplay(i).Caption = rst!Value
next i
How would I do this in VB.NET? I read some books, they mentioned about
using the Tag property to identify the control, but I want to get your
opinion on this.
Thanks!!!

Nov 21 '05 #6
Thanks,

Looks like I have to create the labels in run time, can it be done in design
time?

I used ADODB because I don't know much about ADONET, the project now didn't
allow me much time to research, but certainly now I will look at this in
depth.
"Cor Ligthert" <no************@planet.nl> wrote in message
news:en**************@TK2MSFTNGP10.phx.gbl...
Anthony,

Yes I have answered this often, however it is simple, create yourself that
array of labels and than you can use the code as you do. Using VBNet you can put any control in an array and mixed exactly as you want.

dim myLblArr() as label = new label() {label1,label2,label3,label5,etc)

As question, is there any reason why you use ADODB, with that you have
forever to deploy as well the DLL, why not ADONET?

I hope this helps?

Cor

"anthony"
I know this is probably talk about millions of time here, but I cant seem to find a close one, I am so used to the vb6 control array, now that I
have
to use vb.net for my project, I like to do the following in vb.net with
this
vb6 way:

In vb6, I would create five labels array on a form:
lblDisplay(1)...lblDisplay(5), and in each label I would have tag
property:
Display1...Display5.

Then, in code (omitted some connection string below):

rst = new ADODB.Recordset
for i = 1 to lblDisplay.Count
rst.open("select Value from Tags where Name='" & lblDisplay(i).Tag &
"'")
lblDisplay(i).Caption = rst!Value
next i
How would I do this in VB.NET? I read some books, they mentioned about
using the Tag property to identify the control, but I want to get your
opinion on this.
Thanks!!!


Nov 21 '05 #7
Anthony,

You don't have to create the labels in runtime.
Only that array I showed you, in another format.

dim myLblArr() as label = {label1,label2,label3,label5,etc}

Cor

Nov 21 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Raymond H. | last post by:
Hello, 1- How to see, in a Label, the URL of a link that the mouse pass over? (in the WebBrower control in a vb projet). 2- How to create a menu and a submenu via a button Command1? and...
6
by: Joe | last post by:
I know that the Literal control will not render a <span> tag so I can not format its text. Other than this, what is the difference betwen the Literal control and the LiteralControl Control? How...
31
by: jcrouse | last post by:
Is there a quick and easy way to change the color of a label controls border from the default black to white? Thank you, John
6
by: jcrouse | last post by:
I am rotating some text is some label controls. In the one place I use it it works fine. In the other place I use it I can't figure out the syntax. I don't really understand the event. Where it...
0
by: anthony | last post by:
I know this is probably talk about millions of time here, but I cant seem to find a close one, I am so used to the vb6 control array, now that I have to use vb.net for my project, I like to do...
0
by: Neo | last post by:
hi , i was trying to use textboxes and labels in a repeater control. If in case the value of the text boxes are changed then the changed textbox value and the label has to be added to two...
8
by: Arpan | last post by:
Consider the following code snippet (my main intention is to display the current time in a Label control as & when this ASPX page is accessed/refreshed): <script runat="server"> Class Clock...
2
by: rn5a | last post by:
Consider the following code: <script runat="server"> Sub ShowData(obj As Object, ea As EventArgs) lblDate.Text = DateTime.Now.ToString("d") lblDate.DataBind() End Sub </script> <form...
12
by: vbnewbie | last post by:
I am having problems accessing properties of dynamically generated objects in VB2005. Can someone please help? In a nutshell: My app creates an equal number of checkboxes and labels that share the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.