Hello,
I created an array of label controls like this:
Dim lbl() As Label = {Me.lbl1, Me.lbl2, Me.lbl3}
and was able to iterate through the array. But then I saw
another way to declare the same array:
Dim lbl() As Label = New Label(){Me.lbl1, Me.lbl2, Me.lbl3}
Both ways seems to work fine, but I want to get in the
practice of doing this correctly. Is there a difference
between using New or not for this? If so, what is the
difference?
Thanks,
Ron 4 4906
"Ron" <an*******@discussions.microsoft.com> schrieb: I created an array of label controls like this:
Dim lbl() As Label = {Me.lbl1, Me.lbl2, Me.lbl3}
and was able to iterate through the array. But then I saw another way to declare the same array:
Dim lbl() As Label = New Label(){Me.lbl1, Me.lbl2, Me.lbl3}
Both ways seems to work fine, but I want to get in the practice of doing this correctly. Is there a difference between using New or not for this? If so, what is the difference?
There is no difference. I would prefer the first solution because of the
higher readability.
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
"Ron" <an*******@discussions.microsoft.com> schrieb: I created an array of label controls like this:
Dim lbl() As Label = {Me.lbl1, Me.lbl2, Me.lbl3}
and was able to iterate through the array. But then I saw another way to declare the same array:
Dim lbl() As Label = New Label(){Me.lbl1, Me.lbl2, Me.lbl3}
Both ways seems to work fine, but I want to get in the practice of doing this correctly. Is there a difference between using New or not for this? If so, what is the difference?
There is no difference. I would prefer the first solution because of the
higher readability.
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Ron,
As Herfried suggests I normally use the first syntax, however you need the
second syntax when you want an array, but you don't want or need the
variable.
For example:
Sub Test(labels() As Label)
End Sub
Test(New Label(){Me.lbl1, Me.lbl2, Me.lbl3})
Here I want to send an array of Labels to the Test method, however I don't
want or need an array variable to hold them.
Hope this helps
Jay
"Ron" <an*******@discussions.microsoft.com> wrote in message
news:63****************************@phx.gbl... Hello,
I created an array of label controls like this:
Dim lbl() As Label = {Me.lbl1, Me.lbl2, Me.lbl3}
and was able to iterate through the array. But then I saw another way to declare the same array:
Dim lbl() As Label = New Label(){Me.lbl1, Me.lbl2, Me.lbl3}
Both ways seems to work fine, but I want to get in the practice of doing this correctly. Is there a difference between using New or not for this? If so, what is the difference?
Thanks, Ron
Ron,
As Herfried suggests I normally use the first syntax, however you need the
second syntax when you want an array, but you don't want or need the
variable.
For example:
Sub Test(labels() As Label)
End Sub
Test(New Label(){Me.lbl1, Me.lbl2, Me.lbl3})
Here I want to send an array of Labels to the Test method, however I don't
want or need an array variable to hold them.
Hope this helps
Jay
"Ron" <an*******@discussions.microsoft.com> wrote in message
news:63****************************@phx.gbl... Hello,
I created an array of label controls like this:
Dim lbl() As Label = {Me.lbl1, Me.lbl2, Me.lbl3}
and was able to iterate through the array. But then I saw another way to declare the same array:
Dim lbl() As Label = New Label(){Me.lbl1, Me.lbl2, Me.lbl3}
Both ways seems to work fine, but I want to get in the practice of doing this correctly. Is there a difference between using New or not for this? If so, what is the difference?
Thanks, Ron This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: TR |
last post by:
Is it possible with CSS to prevent this wrapping alignment with a checkbox
with a nested label?
This is the label of the
checkbox that wraps beneath it
I'd prefer it looked like...
|
by: kaiser |
last post by:
Hello, Am new to C# and am playing around trying to get a while loop to
display a int on a windows console using label.
private void btnGo_Click(object sender, System.EventArgs e)
{
int Counter...
|
by: Shapper |
last post by:
Hello,
I am creating a contact form in ASP.NET and I need to access the labels
on Page_Load on my aspx.vb file.
The other elements such as input box and text box don't need to be
accessible....
|
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...
|
by: Phil |
last post by:
Hi,
How to add programmatically a label into a content page?
I tried this but doesn't work:
Thanks
Phil
content page:
|
by: anniejacob |
last post by:
hi,
i want to drag n drop a label from 1 panel to other , when it is dragged to the other panel i want it 2 create another label there in panel2.
i hav written the below code .
public partial...
|
by: CSharpner |
last post by:
How can I do the following?:
Have a label on a form have its Text property bound to a setting from
one of my DLL library's config files?
I've followed these instructions to successfully get...
|
by: THEAF |
last post by:
hi,
i'm tryin to create this math questions form for my sister. the form has 2 labels where random numbers show, a text box where the answer is entered, a next button the next numbers and an exit...
|
by: karthik25 |
last post by:
Hi,
The following code creates a tab container, 5 tab panels, buttons, labels. I was able to add event handlers to the button. But how am i supposed to access the dynamically created labels? For...
|
by: jagdeep gupta |
last post by:
Thanks a lot friend but a problem does occur is i have added a br tag as well but it is not shown in output plz check:
TextBox textBoxArr;
Label lbl=new Label;
Label lblbr=new Label();
...
|
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...
|
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...
|
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...
|
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...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
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)...
|
by: Defcon1945 |
last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
|
by: af34tf |
last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
| |