0
votes

I have 6 String variables: level1, level2, ..., level6, which all of them have String values

Also there is an Integer variable called Nr = 3.

I want to display in some msgboxes all the first three levels such as this: ( with the text: cd in front of the message )

    For incr=1 To Nr
        Msgbox "cd "+level+incr
    Next

But it doesn't show me any prompts.

The body of For function should be after the Next statement? Thanks!

I appreciate your time and your help!

1

1 Answers

4
votes

Build an array

dim StrArray(5) as String

StrArray(0)="Level1"
StrArray(1)="Level2"
StrArray(2)="Level3"
StrArray(3)="Level4"
StrArray(4)="Level5"
StrArray(5)="Level6"

Nr =2

For incr=0 To Nr
    Msgbox "cd " & StrArray(incr) , 0, "Title"
Next