B4J Question Convert int to string and add leading zeros

ranul

Member
Licensed User
Longtime User
Hi,

Is there a built-in function that will take an int and return a formatted string with leading zeros?

For example:
Input: 12, output "0012"
Input: 9, output "0009"

I tried NumberFormat but it added a comma to the output string

Thanks.
 

emexes

Expert
Licensed User
Longtime User
In Ye Olde BASIC I'd often use the equivalent of:
B4X:
Log("Formatted:" & (10000 + 9).As(String).SubString(1))


ie:
B4X:
PRINT "Formatted:" + RIGHT$(STR$(10000 + 9), 4)
 
Last edited:
Upvote 0
Top