LoginSignup
4
0

More than 1 year has passed since last update.

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

Last updated at Posted at 2019-12-09

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ともつながりがあるテクニックです。

4
0
1

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
  3. You can use dark theme
What you can do with signing up
4
0