March 02, 2021, 01:15:13 PM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
Forum
Help
Search
Gallery
Login
Register
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
Miscellaneous
»
[bb] Format a number by skn3 [ 1+ years ago ]
« previous
next »
Print
Pages: [
1
]
Go Down
Author
Topic: [bb] Format a number by skn3 [ 1+ years ago ] (Read 439 times)
BlitzBot
Jr. Member
Posts: 1
[bb] Format a number by skn3 [ 1+ years ago ]
«
on:
June 29, 2017, 12:28:40 AM »
Title :
Format a number
Author :
skn3
Posted :
1+ years ago
Description :
Allows you to format a number and return it in a string.
Code :
Code: BlitzBasic
Print
Format$
(
"345233"
,
"#,###.##"
)
WaitKey
(
)
Function
Format$
(
Number,FormatString$
)
MakeFormat$=
""
NumberCount=
1
For
I=
1
To
Len
(
FormatString$
)
GetFormatChar$=
Mid
$
(
FormatString$,I,
1
)
Select
GetFormatChar$
Case
","
MakeFormat$=MakeFormat$+
","
Case
"."
MakeFormat$=MakeFormat$+
"."
Case
"#"
If
NumberCount >
Len
(
Number
)
Then
GetNumberChar$=
"0"
Else
GetNumberChar$=
Mid
$
(
Number,NumberCount,
1
)
End If
NumberCount=NumberCount+
1
MakeFormat$=MakeFormat$+GetNumberChar$
End Select
Next
Return
MakeFormat$
End Function
Comments :
Mikorians(Posted 1+ years ago)
This didn't work when I fed it a float value.Tried fixing Number refs to Number$, still no good.
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
Miscellaneous
»
[bb] Format a number by skn3 [ 1+ years ago ]
SimplePortal 2.3.6 © 2008-2014, SimplePortal