Android Question Setting a string in list

harinder

Active Member
Licensed User
Longtime User
I am unable to make out the correct syntax for replacing an item in a list with two strings having a colon in between. I tried:

List1.set( 3, ""&RED& ":" &GREEN&"")

Not working.
 

DonManfred

Expert
Licensed User
Longtime User
Add the new item at tje desired postion and remove the next item after the inserted

Or kust replace the item at tje desired index. There is no replace

Search the right index based on the item you want to replace.
Use set on this infex then

Suggestion. Lrarn the öanguage/how to code
 
Upvote 0

harinder

Active Member
Licensed User
Longtime User
Add the new item at tje desired postion and remove the next item after the inserted

Or kust replace the item at tje desired index. There is no replace

Search the right index based on the item you want to replace.
Use set on this infex then

Suggestion. Lrarn the öanguage/how to code
I was just going through documentation for list.
It says:
Set (Index As Int, Item As Object)
Replaces the current item in the specified index with the new item.
So can you please tell me correct syntax for replacing an item at index 3?
List1.set( 3, ""&RED& ":" &GREEN&"") is not working !!
 
Upvote 0

harinder

Active Member
Licensed User
Longtime User
Use this:
List1.Set(3, "RED:GREEN")
or this:
List1.Set(3, "RED" & ":" & "GREEN")
Thanks Klaus..and if I want to replace with gg:hh, where gg and hh are two strings representing 2 digit integers, then will it be:
List1.Set(3, &gg& & ":" & &hh&)? Thnx..
 
Upvote 0

harinder

Active Member
Licensed User
Longtime User
If gg and hh are String variables then:
List1.Set(3, gg & ":" & hh)
if gg and hh are Int variables then:
List1.Set(3, NumberFormat(gg, 2, 0) & ":" & NumberFormat(hh, 2, 0))
Thank you Klaus..That makes it very clear.
 
Upvote 0

udg

Expert
Licensed User
Longtime User
Have a look at Smart String Literals too. It will be something like:
List1.Set(3, $"${gg}:${hh}"$)
or their NumberFormat equivalent.
 
Upvote 0
Top