goto

GoTo <Line number> in VBA

一世执手 提交于 2020-06-24 12:35:07
问题 From the VBA help file: GoTo Statement Branches unconditionally to a specified line within a procedure. Syntax GoTo _ line _ The required line argument can be any line label or line number. Remarks GoTo can branch only to lines within the procedure where it appears. My question is, how can I jump to a line number using GoTo ? (I know how to jump to a label.) (Note: I'm asking this for curiosity's sake. I have no intention of actually using GoTo this way.) 回答1: I understand your dislike of the

How to avoid GOTO in C++

我只是一个虾纸丫 提交于 2020-06-13 08:55:46
问题 I have read that GOTO is bad, but how do I avoid it? I don't know how to program without GOTO . In BASIC I used GOTO for everything. What should I use instead in C and C++? I used GOTO in BASIC like this: MainLoop: INPUT string$ IF string$ = "game" THEN GOTO game ENDIF 回答1: Usually loops like for , while and do while and functions have more or less disposed the need of using GOTO. Learn about using those and after a few examples you won't think about goto anymore. :) 回答2: Consider the

How to avoid GOTO in C++

两盒软妹~` 提交于 2020-06-13 08:55:37
问题 I have read that GOTO is bad, but how do I avoid it? I don't know how to program without GOTO . In BASIC I used GOTO for everything. What should I use instead in C and C++? I used GOTO in BASIC like this: MainLoop: INPUT string$ IF string$ = "game" THEN GOTO game ENDIF 回答1: Usually loops like for , while and do while and functions have more or less disposed the need of using GOTO. Learn about using those and after a few examples you won't think about goto anymore. :) 回答2: Consider the

How to avoid GOTO in C++

自作多情 提交于 2020-06-13 08:55:25
问题 I have read that GOTO is bad, but how do I avoid it? I don't know how to program without GOTO . In BASIC I used GOTO for everything. What should I use instead in C and C++? I used GOTO in BASIC like this: MainLoop: INPUT string$ IF string$ = "game" THEN GOTO game ENDIF 回答1: Usually loops like for , while and do while and functions have more or less disposed the need of using GOTO. Learn about using those and after a few examples you won't think about goto anymore. :) 回答2: Consider the

Understanding T-SQL GOTO

和自甴很熟 提交于 2020-04-17 07:45:21
问题 My teacher recently talked about the statement 'GOTO', to be used in Management Studio, but I didn't quite understand it at first. He stated that GOTO is being used to jump to different pieces of code, with the help of a label I can name by myself. This is the code he used to represent his example: select 'first' goto jump select 'second' jump: select 'third' When I execute the code, sure enough, it prints 'first' and 'third'. My question now is what was the select 'second' doing there in the

Does computed `goto` respect C++ object lifetime?

杀马特。学长 韩版系。学妹 提交于 2020-04-11 02:02:29
问题 Regular goto in C++ respects object lifetime - that is using goto to jump out of a block will run the destructors for the appropriate local variables. start: NonTrivial object; if (again()) goto start; // will call object.~NonTrivial() Is the same true when using the Labels as Values extension? start: NonTrivial object; goto *(again() ? &&start : &&end); end: GCC happily accepts this code, but seems to ignore any effect goto might have on object 's lifetime. clang complains. Look for calls to

goto unexpected with blank choice

青春壹個敷衍的年華 提交于 2020-02-05 05:17:07
问题 My problem: I set a VAR with prompt and three IF to let choice. Fourth choice doesn't work. I would like that if i push enter without type anything, it goes back to :MOSTRA. Actually leaving it blank and typing enter on the keyboard it give back GOTO WAS UNEXPECTED and close CMD. Where am i wrong? :MOSTRA ECHO Make your choice. ECHO. ECHO A) Ok ECHO B) Ko ECHO Esci SET /P choose=Scelta: if /I %choose%==A GOTO OK if /I %choose%==B GOTO KO if /I %choose%==esci GOTO FINE if /I %choose%=="" GOTO

Understand the pro and cons of the GoTo statement

三世轮回 提交于 2020-01-25 08:34:07
问题 I'm working with excel vba since 3 month now and this is (after one course of programming in university) my first real contact to programming. Please take that to account. I built up a userform with many textboxes. Therefore I wrote a makro which first checks if the user put in a value in every textbox so that afterwards the procedure begins. If there is not a value in every textbox I want the exit sub after msgbox the user to fill again every textbox. Quiet simple, right? I thought the best

Should I avoid “goto” in situations like this?

我的未来我决定 提交于 2020-01-24 09:22:28
问题 I was making a "concatenating iterator", i.e. an iterator that would iterate over the int s in an int** . Its constructor needs: An array of T** , representing the beginning of each sub-array. An array of T** , representing the end of each sub-array. Lo and behold, I ran across a situation where goto seemed to be appropriate. But something within me screamed "NO!!" so I thought I'd come here and ask: Should I try avoid goto situations like this? (Does it improve the readability if I do?)

only do if day… batch file

本秂侑毒 提交于 2020-01-12 05:25:23
问题 hello i got a batch file, something like this: if %day%==monday, tuesday, wednesday, thursday, friday ( goto yes ) else ( goto no ) Now i know the first line won't work. What i actually want to happen: It automatticly checks which day it is. If it is Monday to Friday, it has to go to 'yes', otherwise (saturday/sunday) to 'no'. How to do this? 回答1: I ran across this online. Tested, and it works. Returns the day as an integer, which you can still work with. @For /F "tokens=2,3,4 delims=/ " %%A