Problem using variable in 'Colors.ARGB'

rickrack

Member
Licensed User
Longtime User
Hello, I would like to change a label text color by downloading a string from an online stored .txt file that contains requested values xxx, xxx, xxx, xxx but I get an error when I try to debug the app.

Sub hc_avversario_ombra_ResponseSuccess(Response As HttpResponse, TaskId As Int)

data_avversario_ombra.TextColor = Colors.ARGB(Response.GetString("UTF8"))

End Sub

Compiling code. Error
Error compiling program.
Error description: Missing parameter.
Occurred on line: 124
data_avversario_ombra = Colors.ARGB(Response.GetString("UTF8"))
Word: )


Please help me.. I'm trying to solve this from 2 days but no results :((

thanks in advance
 
Last edited:

lagore

Active Member
Licensed User
Longtime User
Put a line to log the value that you are downloading to make sure it is the correct format

Sent from my HTC One X using Tapatalk 2
 
Upvote 0

NJDude

Expert
Licensed User
Longtime User
That will fail because ARGB expects 4 integers, you will have to parse the result like this:
B4X:
Dim Values() As String
Dim Result As String

Result = Response.GetString("UTF8")

Values = Regex.Split(",", Result)

data_avversario_ombra.TextColor = Colors.ARGB(Values(0), Values(1), Values(2), Values(3))

I haven't tested the code but it should work.
 
Last edited:
Upvote 0

rickrack

Member
Licensed User
Longtime User
I did it as margret advised using njdude code ;)
thank you for rapid support!
There's just a problem in yours, njdude: "values" must be string too because the split can't use two different types of variables

thanks, have a nice day!
 
Last edited:
Upvote 0

NJDude

Expert
Licensed User
Longtime User
There's just a problem in yours, njdude: "values" must me string too because the split can't use two different types of variables

I wrote that code from the top of my head, I wasn't sure about that, that's why I advised caution. :D

I have modified the code in case someone else wants to do the same.

Thanks.
 
Upvote 0
Top