-1
我被要求做的是把一个用户输入作为一个整数。例如,6是输入。 6变成等式(6-1)*(6)/ 2,这相当于15对。然后,我再调用另一个将输入处理为{for next}循环的子集。我有一个If语句来检查重复项,但它是有限的。我曾尝试将迭代变量传入if语句中,但这样做无法正常工作。VBA匹配对没有重复
下面是代码:
For intOuter = 1 To options - 1
'The intInner loop cycles through and sets up the loop for the combination and determines if
'the combination has been made already
For intInner = 1 To options
'If statement tests if a combination has already been made if it has it will not be printed
'if it has not been combined then it will be printed to the immediate window
If intOuter <> intInner And intOuter <> value + 1 And intOuter <> value + 2 And intOuter <> value + 3 _
And intOuter <> value + 4 Then
Debug.Print intOuter & " vs " & intInner & " Actual"
End If
Next intInner
Next intOuter
输出这个例子正确显示将是(与6的用户输入)预先
1vs2
1vs3
1vs4
1vs5
1vs6
2vs3
2vs4
2vs5
2vs6
3vs4
3vs5
3vs6
4vs5
4vs6
5vs6
谢谢我很欣赏它。
好像你只是想intInner比intOuter ... – Joffan