LoginSignup
0

posted at

updated at

Organization

VBScriptでC言語のcontinue相当の処理を行う方法

VBScriptにはC言語のcontinueやRubyのnextに相当するような、現在のイテレーションをスキップする機能がありません。
Do Whileを使うことによって、continueと等価な処理を行う事ができます。

For i = 0 To 10
  Do
    If i = 5 Then
      Exit Do
    End If
    WScript.Echo(i)
  Loop While False
Next

これによって、ネストが1段深くなってしまい可読性が落ちてしまいますが、どうしても今のイテレーションをスキップしたいときのテクニックとして活用ください。

なお、このテクニックはいわゆる去勢されたGOTOともつながりがあるテクニックです。

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
What you can do with signing up
0