I notice that if a I Dim a String Array and load it with a mix of Text and String members, the WebListBox.AddRow method (which currently only accepts String rows) will work fine because that Array will be seen as a String Array, even though some of its members are Text. But if all the members of that Array are Text, it will fail because that array is now seen as a Text Array.
Is this way of working with Arrays working as designed? That is, Xojo sees an Array that is a mix of Text and String members as a String Array, at least in terms of loading that Array of rows into a WebListBox.
Should I worry that a future version of Xojo might see that Array that contains a mix of Text and String members as improperly formed?
Dim row() As String
Dim s As Text = "This is text."
Dim t As Text = "This is more text."
row = Array(s, t)
The latter yields this
Type mismatch error. Expected String(), but got Text()
row = Array(s, t)
Of course, this will compile:
Dim row() As Text
Dim s As Text = "This is text."
Dim t As Text = "This is more text."
row = Array(s, t)
but this will not:
Dim row() As Text
Dim s As Text = "This is text."
Dim t As Text = "This is more text."
row = Array(s, t)
ListBox1.AddRow(row)
The latter yields
There is more than one item with this name and it's not clear to which this refers.
ListBox1.AddRow(row)
But if I mix String and Text in the Array, everything works fine. This compiles and works:
Dim row() As String
Dim arr() As String
Dim s As String = "This is a string."
Dim t As Text = "This is text."
arr = Array(s, t)
row = arr
ListBox1.AddRow(row)
[quote=370039:@Michel Bujardet]Dim row() As String
Dim s As Text = “This is text.”
Dim t As Text = “This is more text.”
row = Array(s, t)
ListBox1.AddRow(row)[/quote]
WebPage1.Button3.Action, line 4
Type mismatch error. Expected String(), but got Text()
row = Array(s, t)
[quote=370040:@Antonio Rinaldi]Array( t1, t2) … just to be clear in your notation… create a new array and it’s build on text and text so it’s text()
and again text() is not string()[/quote]
So, if the array is built on a mixture of String members and Text members, then it will be considered String. If it is built on only Text members, it will be built as Text. Eventhough I declared the array as String.