LoginSignup
0
0

More than 3 years have passed since last update.

VBSからPowerShellへ (3)反復処理

Last updated at Posted at 2019-05-19

VBSで書かれたプログラムをPowerShellに置き換える場合、反復処理については以下のようになる。

'VBSでループ

'forによるループ
for c = 1 to 5
 ・・・
 (処理)
 ・・・
Next

'whileによるループ(1)
dim i
i =0
do while i < 6
 ・・・
 (処理)
 ・・・

 i = i + 1
loop


'whileによるループ(2)
dim j
j =0
do
 ・・・
 (処理)
 ・・・

 j = j + 1
loop While j < 7
#PowerShellでループ

#forによるループ
for($c=1; $c -le 5; $c++) {
 ・・・
 (処理)
 ・・・
}

#whileによるループ(1)
$i = 0
while ($i -lt 6) {
 ・・・
 (処理)
 ・・・

 $i++;
}

#whileによるループ(2)
$j = 0
do {
 ・・・
 (処理)
 ・・・

 $j++;
} while ($j -lt 7)

・参考にさせていただいたページ
【PowerShell】繰り返し文(While, For)について
[https://soma-engineering.com/coding/powershell/loop-while-for/2018/06/09/]

0
0
0

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
0
0