对于下一个循环 - 增加变量

时间:2014-11-17 19:10:32

标签: vb.net for-loop

我有一个基本的下一个循环。

For x = 1 to 100
    test = Test +110
    if test > 500
        counter = Counter +1
    end if

    MsgBox (thisisatest)
Next

我想做什么,每当计数器增加时,最多增加1。例如。

If counter = '1' it should be 'thisisatest1'
If Counter = '2' it should be 'thisisatest2'
If counter = '3' it should be 'thisisatest3'

2 个答案:

答案 0 :(得分:1)

For x = 1 to 100
    test = Test +110
    if test > 500
        counter = Counter +1
    end if

    MsgBox (thisisatest+counter)
Next

答案 1 :(得分:0)

每次计数器增加时,你可以将变量增加1,如下所示:

For x = 1 to 100
    test = Test +110
    if test > 500
        counter = Counter +1
        thisisatest &= x
    end if

    MsgBox (thisisatest)
Next