C/C++ 'продолжается' Эквивалентный в VB6

Замена активного ингредиента следующим сделала свое дело.

CategoryGrid[row.names(CategoryGrid) == Origin , colnames(CategoryGrid) == Dest] <- apply(CategoryGrid[row.names(CategoryGrid) == Origin , colnames(CategoryGrid) == Dest], MARGIN=c(1,2),function(x) ifelse(x == Distance, Final, x))

Укажите правила для строк и столбцов, а затем примените и поместите третью переменную в свою собственную функцию.

22
задан Steven 6 May 2009 в 18:46
поделиться

4 ответа

There is no equivalent in VB6, but later versions of VB do introduce this keyword. This article has a more in-depth explanation: http://vbnotebookfor.net/2007/06/04/the-continue-statement/

Perhaps you can restructure your code to either add an if statement or have the loop just call a function that you can return from.

20
ответ дан 29 November 2019 в 05:04
поделиться

VB6 не имеет оператора continue для циклов. Вы должны эмулировать его, используя goto, if или другой цикл.

//VB.net
do
    if condition then continue do
    ...
loop
//VB6 equivalent (goto)
do
    if condition then goto continue_do
    ...
continue_do:
loop
//VB6 equivalent (if)
do
    if not condition then
        ...
    endif
loop

Вы не можете использовать «exit while» в VB6. Но вы можете использовать goto.

While condition

    if should_skip then goto mycontinue

    'code

    if should_break then goto outloop

   mycontinue:

Wend

outloop:
7
ответ дан 29 November 2019 в 05:04
поделиться

Sadly there is no Continue if VB6 - this was new in VB 2005 I believe.

I wouldn't always be afraid of goto statements - that's effectively what the Continue is, but without the need for a labelled line after the loop. As long as your goto statements don't jump very far, they will always be readable, and it is probably the most elegant solution to this problem.

Nesting another if/then/else inside a for loop is actually HARDER to read and maintain later than a nice simple goto (with a comment on the goto line saying something like "' read as Continue For").

Good luck!

6
ответ дан 29 November 2019 в 05:04
поделиться

Я идиот: P спасибо MarkJ

   For index As Integer = 1 To 10
        If  index=9 Then
            Continue For
        End If
   'some cool code'
    Next

Нет, извините только за .net. Я думаю, что вы должны использовать goto, я знаю, что для продолжения маршрут выглядит «чище», но нет ничего плохого в том, чтобы идти по маршруту if.

неверно.

 Continue:
     For index As Integer = 1 To 10
                If index=9 Then
                  GoTo Continue
                End If
    'some cool code'
     Next

исправлено (?)

     For index = 1 To 10
      If index=9 Then
       GoTo Continue 
      End If    
    'some cool code'
Continue:
     Next

ненависть В.Б.

2
ответ дан 29 November 2019 в 05:04
поделиться
Другие вопросы по тегам:

Похожие вопросы: