Convert Bytes to the Appropriate Format (Bytes, KB, MB, GB)

Category:
Dates and Math
Type:
Snippets
Difficulty:
Beginning
Author:
Anonymous

Version Compatibility:

More information:
Convert bytes to the best format (Bytes, KB, MB, GB)

Examples:

  • SetBytes(74) 'returns "74 Bytes"
  • SetBytes(5037) 'returns "4.92 KB"
  • SetBytes(6383838) 'returns "6.09 MB"
  • SetBytes(3368383278) 'returns "3.14 GB"

Instructions: Copy the declarations and code below and paste directly into your VB project.

Declarations:

Code: