|
|
Title | Format a number of bytes in KB, MB, and GB by using StrFormatByteSize in VB .NET |
Description | This example shows how to format a number of bytes in KB, MB, and GB by using StrFormatByteSize in VB .NET. |
Keywords | format, bytes, KB, MB, GB, StrFormatByteSize, VB.NET |
Categories | API, Files and Directories |
|
|
The FormatBytes function uses the StrFormatByteSize API function.
|
|
' Return a formatted string representing
' the number of bytes.
Private Function FormatBytes(ByVal num_bytes As Int32) As _
String
Dim txt As String
txt = Space$(256)
StrFormatByteSize(num_bytes, txt, Len(txt))
FormatBytes = txt.Substring(0, txt.IndexOf(vbNullChar))
End Function
|
|
See also:
|
|
|
|
|
|