Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
jackhand
Level 7

StrI() Function create whitespace

I noticed the StrI() Function create whitespace in front of the string. For example the following operation StrI(3) produces the following string " 3" instead of "3".

The following is how I am currently eliminating the leading whitespace; however, is there a better way?

sString = StrI(n)
nWhitespace = Instr(1, sString , " ")
if nWhitespace = 1 then
   sString = Mid(sString , 2)
end if

0 Kudos
1 Reply
tim_beynart
Level 7

Re: StrI() Function create whitespace

The space is there for the negative sign. Use toStr() on the number instead. https://sdkdocs.roku.com/display/sdkdoc/ifToStr

myInteger = 12345
myIntegerString = myInteger.ToStr()
0 Kudos