如何在visual basic c ++中使用goto命令? [英] How to use goto command in visual basic c++ ?

查看:99
本文介绍了如何在visual basic c ++中使用goto命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经获得了一个项目来准备一个板球项目

记分牌...现在当所有10个小门都掉下来时我想要我的程序去

到end..lets在第50行说。

goto语句的语法是什么.... plz给我一个迷你的例子,如果你可以的话,那就是

。 />
thanx。

解决方案




在C / C ++


转到_Label1;

休息;

}

_State = 1;

返回eQuickSaveGame;

_Label1:

返回eFinished;

}


但是我假设你实际上是指Visual Basic,

来自msdn(你可以自己做一个搜索,你知道):


Sub gotoStatementDemo()

Dim number As Integer = 1

Dim sampleString As String

''评估数字并分支到适当的标签。

如果number = 1那么GoTo Line1 Else GoTo Line2

Line1:

sampleString =" Number equals 1"

GoTo LastLine

Line2:

''以下语句永远不会被执行,因为number = 1。 br />
sampleString ="数字等于2>

LastLine:

''写'数字等于1"在调试窗口中。

Debug.WriteLine(sampleString)

结束子


问候,Ron AF Greve

http://moonlit.xs4all.nl

" fa *********** @ hotmail.com" < fa *********** @ gmail.comwrote in message

news:11 ******************* ***@48g2000cwx.googlegro ups.com ...


>我已经获得了一个项目来准备板球项目

记分牌......现在当所有的10个小门都掉下来时我想让我的程序走到最后..
到最后..小组说在第50行。

是什么语法goto声明....请给我一个迷你的例子

如果可以的话。

thanx。



" FA *********** @ hotmail.com" < fa *********** @ gmail.comwrote in message

news:11 ******************* ***@48g2000cwx.googlegro ups.com ...


>我已经获得了一个项目来准备板球项目

记分牌......现在当所有的10个小门都掉下来时我想让我的程序走到最后..
到最后..小组说在第50行。

是什么语法转到声明....请给我一个小例子,如果可以,请给我一个b $ b。

thanx。



如果忘记goto语句,你会感谢自己。

goto stratment不属于结构化的langague。当使用goto实际上有意义时,有很少的例外情况,但如果你看看

任何专业代码,你甚至不应该看到goto语句。 />

当所有10个小门落下时,返回。出口。设置一个标志。除了使用

goto:D


你好!

fa *********** @ hotmail.com 写道:


我已经获得了一个项目来准备板球项目

记分牌...现在当所有10个门票都掉下来时我想要我的程序去

到end..lets在第50行说。

goto语句的语法是什么.... plz给我一个迷你的例子,如果你可以的话,那就是

。 />
thanx。



Goto是邪恶的。 (在FAQ中查看Evil。)Goto非常邪恶。 Goto是

非常适合写意大利面条代码。


Simon


-

如果我在我的.signature中提到Leader Kibo会怎样?


I have been given a project to prepare a program for cricket
scoreboard...now when all the 10 wickets fall I want my program to go
to the end..lets say on line 50.
what is the syntax of goto statement....plz give me a mini example for
it if u can.
thanx.

解决方案

Hi,

In C/C++

goto _Label1;
break;
}
_State = 1;
return eQuickSaveGame;
_Label1:
return eFinished;
}

However I assume you actually mean Visual Basic,
From msdn (you could have done a search yourself, you know):

Sub gotoStatementDemo()
Dim number As Integer = 1
Dim sampleString As String
'' Evaluate number and branch to appropriate label.
If number = 1 Then GoTo Line1 Else GoTo Line2
Line1:
sampleString = "Number equals 1"
GoTo LastLine
Line2:
'' The following statement never gets executed because number = 1.
sampleString = "Number equals 2"
LastLine:
'' Write "Number equals 1" in the Debug window.
Debug.WriteLine(sampleString)
End Sub

Regards, Ron AF Greve

http://moonlit.xs4all.nl

"fa***********@hotmail.com" <fa***********@gmail.comwrote in message
news:11**********************@48g2000cwx.googlegro ups.com...

>I have been given a project to prepare a program for cricket
scoreboard...now when all the 10 wickets fall I want my program to go
to the end..lets say on line 50.
what is the syntax of goto statement....plz give me a mini example for
it if u can.
thanx.



"fa***********@hotmail.com" <fa***********@gmail.comwrote in message
news:11**********************@48g2000cwx.googlegro ups.com...

>I have been given a project to prepare a program for cricket
scoreboard...now when all the 10 wickets fall I want my program to go
to the end..lets say on line 50.
what is the syntax of goto statement....plz give me a mini example for
it if u can.
thanx.

You will thank yourself if you forget the goto statement even exists. The
goto stratment does not belong in a structured langague. There are very
rare exceptions when using a goto actually make sense, but if you look at
any professional code you shouldn''t even see a goto statement.

When all the 10 wickets fall, return. Exit. Set a flag. Anything but use a
goto :D


Hello!

fa***********@hotmail.com wrote:

I have been given a project to prepare a program for cricket
scoreboard...now when all the 10 wickets fall I want my program to go
to the end..lets say on line 50.
what is the syntax of goto statement....plz give me a mini example for
it if u can.
thanx.

Goto is Evil. (Look Evil up in the FAQ.) Goto is Very Evil. Goto is
very good for writing spaghetti code with.

Simon

--
What happens if I mention Leader Kibo in my .signature?


这篇关于如何在visual basic c ++中使用goto命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆