How to assign a set of text values ​​to an array of strings?

How to assign a set of text values ​​to an array? Nothing I tried works!

Months = Array("Jan", "Feb", ..., "Dec")

and the others I tried do not work!

+4
source share
3 answers

Here's something about VB: http://www.devx.com/vb2themax/Tip/18322

Visual Basic provides no way to declare an array and initialize its elements at the same time. In most cases, when you finish the installation of individual elements one by one, as in:

  Dim strArray(0 To 3) As String
  strArray(0) = "Spring" 
  strArray(1) = "Summer"
  strArray(2) = "Fall"
  strArray(3) = "Winter"

Under VB4, VB5 and VB6, you can create an array of options on the fly using the Array () function:

  Dim varArray() As Variant 
  varArray() = Array("Spring", "Summer", "Fall", "Winter")

, . , VB6, String, Split():

  Dim varArray() As String 
  ' arrays returned by Split are always zero-based 
  varArray() = Split("Spring;Summer;Fall;Winter", ";")
+15

, :

 dim months(2) as string

 months(0) = "Jan"
 months(1) = "Feb"
 months(2) = "Mar"
+1

If you are talking about vbscript then this works:

months = Array("may","june","july")

If it is vb.net, then:

dim months() as string = {"may","june","july"}
+1
source

Source: https://habr.com/ru/post/1702642/


All Articles