Advertisements

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" <> wrote in message
news:%23WeEI$...
> 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
>
>

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)" <> wrote in
message news:%...
> 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" <> wrote in message
> news:%23WeEI$...
> > 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
> >
> >
>
>

Share This Page

Welcome to The Coding Forums!

Welcome to the Coding Forums, the place to chat about anything related to programming and coding languages.

Please join our friendly community by clicking the button below - it only takes a few seconds and is totally free. You'll be able to ask questions about coding or chat with the community and help others.
Sign up now!