Mirage Source
1000 to 1k converter - Printable Version

+- Mirage Source (https://mirage-engine.uk/forums)
+-- Forum: Mirage Source (Nostalgia) (https://mirage-engine.uk/forums/forumdisplay.php?fid=61)
+--- Forum: Archive (2006-2011) (https://mirage-engine.uk/forums/forumdisplay.php?fid=18)
+---- Forum: Programming (https://mirage-engine.uk/forums/forumdisplay.php?fid=24)
+----- Forum: Visual Basic 6 (https://mirage-engine.uk/forums/forumdisplay.php?fid=32)
+----- Thread: 1000 to 1k converter (/showthread.php?tid=3167)



1000 to 1k converter - Matt - 30-09-2009

I was wondering if someone could write a function that will take a value of like, 1000 and turn it into 1k or 100,000 and turn it into 100k.

Thanks. Big Grin


Re: 1000 to 1k converter - DarkSpartan4 - 30-09-2009

Can't you just make it divide the number by 1000 and add a "k" to the end of it?


Re: 1000 to 1k converter - Matt - 30-09-2009

DarkSpartan4 Wrote:Can't you just make it divide the number by 1000 and add a "k" to the end of it?

I prolly could, but I'd like it to round down so I don't have 1.6828194k


Re: 1000 to 1k converter - Robin - 30-09-2009

Already have one Big Grin

Code:
Public Function ConvertCurrency(ByVal Amount As Long) As String
    If Int(Amount) < 10000 Then
        ConvertCurrency = Amount
    ElseIf Int(Amount) < 999999 Then
        ConvertCurrency = Int(Amount / 1000) & "k"
    ElseIf Int(Amount) < 999999999 Then
        ConvertCurrency = Int(Amount / 1000000) & "m"
    Else
        ConvertCurrency = Int(Amount / 1000000000) & "b"
    End If
End Function



Re: 1000 to 1k converter - Matt - 30-09-2009

Awesome. Thanks! Big Grin