R ranul Member Licensed User Longtime User Feb 13, 2025 #1 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.
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.
DonManfred Expert Licensed User Longtime User Feb 13, 2025 #2 B4X: Dim number As Int = 9 Log($"Formatted: ${NumberFormat2(number,4,0,0,False)}"$) Formatted: 0009 Click to expand... Upvote 1
B4X: Dim number As Int = 9 Log($"Formatted: ${NumberFormat2(number,4,0,0,False)}"$) Formatted: 0009 Click to expand...
E emexes Expert Licensed User Longtime User Feb 13, 2025 #4 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: Feb 13, 2025 Upvote 0
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)