473,382 Members | 1,332 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,382 software developers and data experts.

For what use LABELS (left of the code) in Visual Basic Code?

Hello,

for what is the LABEL good when programming in visual studio like this:

Sub xxxx

Label1: xxxx
xxxx
xxx

Label2: xxxxx

End Sub

For what do I need or can use "Label1" and "Label2" in my Visual Studio Code
?

Thanks for any help an answers in advance!
Andreas
Nov 18 '05 #1
3 1326
Labels are a bit of a leftover from VB 6, IMO. The idea is being able to use
Goto statements to go to a specific label. For example:

Public Sub TestGoto()

Dim DataSetNumber As Integer = 1

RetrieveData:
Dim ds As DataSet = GetData(DataSetNumber )

For x = 1 to 100

'Assume if there is a "duck" then you go to retrieve data again
If ds.Tables[0].Rows[1]["Animal"] = "duck"
DataSetNumber += 1
Goto RetrieveData
End If
Next x

End Sub

This is a very bad example, as I can see no real use for labels any more,
but it illustrates that you can use it for flow control. In general, you
will find that proper architecture will not lead you to solutions where you
use labels.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************** ********************
Think Outside the Box!
************************************************** ********************
"Andreas Klemt" <ak******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hello,

for what is the LABEL good when programming in visual studio like this:

Sub xxxx

Label1: xxxx
xxxx
xxx

Label2: xxxxx

End Sub

For what do I need or can use "Label1" and "Label2" in my Visual Studio Code ?

Thanks for any help an answers in advance!
Andreas

Nov 18 '05 #2
A label can be used as a target for the "goto" or "gosub" statement (which
are generally avoided). It's perhaps also considered sometimes by some
people as a way to "document" things (?).

My personal opinion is that this is basically useless.

Patrice

--

"Andreas Klemt" <ak******@hotmail.com> a écrit dans le message de
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hello,

for what is the LABEL good when programming in visual studio like this:

Sub xxxx

Label1: xxxx
xxxx
xxx

Label2: xxxxx

End Sub

For what do I need or can use "Label1" and "Label2" in my Visual Studio Code ?

Thanks for any help an answers in advance!
Andreas


Nov 18 '05 #3
At the risk of revealing my age... It's actually a hold over from a lot
further than VB6.

Can anyone say QuickBASIC (GW-BASIC if you include line numbers in that)
?!?!
Regards
Brian W

"Cowboy (Gregory A. Beamer)" <No************@comcast.netNoSpamM> wrote in
message news:%2****************@TK2MSFTNGP12.phx.gbl...
Labels are a bit of a leftover from VB 6, IMO. The idea is being able to use Goto statements to go to a specific label. For example:

Public Sub TestGoto()

Dim DataSetNumber As Integer = 1

RetrieveData:
Dim ds As DataSet = GetData(DataSetNumber )

For x = 1 to 100

'Assume if there is a "duck" then you go to retrieve data again
If ds.Tables[0].Rows[1]["Animal"] = "duck"
DataSetNumber += 1
Goto RetrieveData
End If
Next x

End Sub

This is a very bad example, as I can see no real use for labels any more,
but it illustrates that you can use it for flow control. In general, you
will find that proper architecture will not lead you to solutions where you use labels.

--
Gregory A. Beamer
MVP; MCP: +I, SE, SD, DBA

************************************************** ********************
Think Outside the Box!
************************************************** ********************
"Andreas Klemt" <ak******@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP09.phx.gbl...
Hello,

for what is the LABEL good when programming in visual studio like this:

Sub xxxx

Label1: xxxx
xxxx
xxx

Label2: xxxxx

End Sub

For what do I need or can use "Label1" and "Label2" in my Visual Studio

Code
?

Thanks for any help an answers in advance!
Andreas


Nov 18 '05 #4

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

Similar topics

0
by: madeo | last post by:
hi, i'm looking for some script which would export address labels from a mysql db to pdf ... There's an exapmle, but i'm not able to convert it for using with mysql ... can anybody help? THX...
7
by: Jared | last post by:
Here is my situation. I have multiple labels on a form but only certain ones will become visible while using the form. Depending on which check box(s) you pick, on another form, determines the...
7
by: John Øllgård Jensen | last post by:
Hi Using MS Asccess 2000: In a query I'm trying to create a new field with following expression: FilmDate: Left(,4) The field "FilmNo" is another text field in the query. This is...
10
by: MCourbois | last post by:
Hi, I'm trying to create a programme which generates a matrix with variable sized rows and columns. Now to reduce the amount of useless code i want to have it so that the labels are automatically...
1
by: MCourbois | last post by:
Hi, Im trying to generate some labels in a programme i am making but it's not going too well. I've tried debugging the programme and it goes trough the entire code without problems. But i don't...
5
by: Mel | last post by:
I created a header that adjusts with the size of the browser windows. How do I place labels in the header section so they also maintain their position when the window is resized? One of the labels...
8
by: qwer | last post by:
How do I display each label one by one automatically on the form using Visual Basic? And how do I extract the information from the SMS and insert it into the labels when I connect the GSM modem to...
32
by: Greg | last post by:
I know I can use the Microsoft.VisualBasic.Left function to get the left portion of a string, but I would prefer to avoid using any Microsoft.VisualBasic namespace items. What is the equivilant in...
2
by: divyac | last post by:
I have developed an address book using php and mysql.I have all the contacts list in a table with check boxes.Now that i want to create mailing labels for the checked contacts...i.e.,the arrangements...
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.