Brian_Max
(Brian Max)
1
This works:
Dim s As String = "StringValue"
Dim d As New Dictionary
d.Value(s) = "Dictionary Value"
MsgBox(d.Value("StringValue"))
But this does not:
Dim t As Text = "TextValue"
Dim d As New Dictionary
d.Value(t) = "Dictionary Value"
MsgBox(d.Value("TextValue"))
I get KeyNotFoundException. Now my question is WHY and what’s the correct way for using Text variables with this example?
Eli_Ott
(Eli Ott)
2
[code]Dim t As Text = “TextValue”
Dim d As New Dictionary
d.Value(t) = “Dictionary Value”
MsgBox(d.Value(“TextValue”)) < “TextValue” is a String, not a Text[/code]
So either prepend the code with
Using Xojo.Core
or do this conversion:
MsgBox(d.Value(CType("TextValue", Text)))
Brian_Max
(Brian Max)
3
Always thought Text and String types are interchangeable. Oh well…
Text has an implicit conversion to String, but not the other way. That is why you have to use .toText for a string to be affected to a Text variable.