Auto Text to Color

Need to change Text to Color, Here is old code:

Function Pref2Color(s as String) As color dim v as Variant v = s return v End Function

For IOS change it to:

Function Pref2Color(s as text) As color dim v as Auto v = s return v End Function

I get a run time TypeMismatchException.

How do I do this?

Auto variables do not convert between data types like Variant does. So you cannot assign a String to a Color.

I’m not sure how your color String is formatted, but for iOS you’ll likely want to use the Color.RGB method after getting the specific color values from your text.

Thanks Paul. Here is my solution,

[code]
dim v as Color
dim RGB(4) as integer

dim x as text
x = t.Mid(4,2)
RGB(0) = Integer.Fromhex(x)
x = t.Mid(6,2)
RGB(1) = Integer.Fromhex(x)
x = t.Mid(8,2)
RGB(2) = Integer.Fromhex(x)
RGB(3) = 0
v = color.rgba(rgb(0),rgb(1),rgb(2),rgb(3) )
return v[/code]