Search code examples
arraysexcelvbamessagebox

I am having issues with showing the output of my array in a message box


I am trying to show the output of an array that has been defined as a string in VBA Excel. However, I am not getting the output I am looking for. This is my code:

Sub myArray()
    Dim dayArray(0 To 6) As String
        i = dayArray(i)
        dayArray(0) = "Sunday"
        dayArray(1) = "Monday"
        dayArray(2) = "Tuesday"
        dayArray(3) = "Wednesday"
        dayArray(4) = "Thursday"
        dayArray(5) = "Friday"
        dayArray(6) = "Saturday"
    For i = 0 To 6
        MsgBox "Today is "
    Next
End Sub

I am trying to output the day of the week based on the string. How can I make sure that I get the day as the message box?


Solution

  • Just to close this question out:

    Sub myArray()
        Dim dayArray(0 To 6) As String
    
        dayArray(0) = "Sunday"
        dayArray(1) = "Monday"
        dayArray(2) = "Tuesday"
        dayArray(3) = "Wednesday"
        dayArray(4) = "Thursday"
        dayArray(5) = "Friday"
        dayArray(6) = "Saturday"
    
        Dim i as Long
        For i = 0 To 6
            MsgBox "Today is " & dayArray(i)
        Next
    End Sub