读取for循环中

时间:2017-04-11 16:25:44

标签: ms-access

在下面的代码中...... 值kk1 =“1”,kk2 =“2”,kk3 =“3”,kk4 =“4”。

我希望msgbox显示一,二,三和四而不是KK1,KK2,KK3和KK4

For i = 1 To 4
    vari_value = "kk" & i
    MsgBox vari_value
Next

1 个答案:

答案 0 :(得分:1)

通过使用可以实现的选择案例陈述,请参考下面的代码,循环从1到4,值为" KK1"," KK2"," KK3&# 34;," KK4"

Public Sub run()
For i = 1 To 4
vari_value = "kk" & i
Select Case vari_value
    Case Is = "kk1"
        MsgBox "One"
    Case Is = "kk2"
        MsgBox "Two"
    Case Is = "kk3"
        MsgBox "Three"
    Case Is = "kk4"
        MsgBox "Four"
End Select
'MsgBox vari_value
Next
End Sub

希望这能解决你的问题。