Declare and Initialize String Array in VBA

前端 未结 6 1689
刺人心
刺人心 2020-11-28 02:54

This should work according to another stack overflow post but its not:

Dim arrWsNames As String() = {\"Value1\", \"Value2\"}

Can anyone let

6条回答
  •  爱一瞬间的悲伤
    2020-11-28 03:36

    Dim myStringArray() As String
    *code*
    redim myStringArray(size_of_your_array)
    

    Then you can do something static like this:

    myStringArray = { item_1, item_2, ... }
    

    Or something iterative like this:

    Dim x
    For x = 0 To size_of_your_array
        myStringArray(x) = data_source(x).Name
    Next x
    

提交回复
热议问题