如何获取数组中的下一个值以在循环中使用条件。
dim x(10) as integer
dim d1,d2 as integer
for i = 0 to 10
d1 = x(1) 'first value in an array e.g. is 10
d2 = x(2) 'second value in an array e.g. is 20
if (d2-d1) > 1 then
Msgbox "Item Count"
else
msgbox "Item Deleted"
end if
next i
答案 0 :(得分:0)
如果我正确理解您的要求,您需要使用带有for循环的步骤关键字,如下所示:
Dim x(10) As Integer
Dim d1, d2 As Integer
Dim i As Integer
For i = 0 To 8 Step 2
d1 = x(i + 1) 'first value in an array e.g. is 10
d2 = x(i + 2) 'second value in an array e.g. is 20
If (d2 - d1) > 1 Then
MsgBox "Item Count"
Else
MsgBox "Item Deleted"
End If
Next i