Multiple Variable getting created within a loop RRS feed

  • Question

  • User-857155513 posted

    tried to do the following and didnt work.  I am basically trying to create the variable month for the number of times it goes through the loop   Any help would be appreciated.


    While loopcnt <= numbermonths

      Dim (“Month “ & loopcnt)  as integer

      Loopcnt += 1

    End while


    Tuesday, June 3, 2008 2:48 AM

All replies

  • User746351338 posted


    You cannot create variables in this way. I would rethink your approach and use a dictionary based storage mechanism like an ArrayList, HashTable or SortedList:

    Dim months As New SortedList
    For m As Integer = 1 To 12
    months("Month " & m) = m
    For Each entry As DictionaryEntry In months
        Response.Write(entry.Key & " = " & entry.Value & "<br />")
    Tuesday, June 3, 2008 3:30 AM