Vbscript / User Interaction / Convert Byte Value To Kb-mb-gb-tb
Convert value in Bytes to an integer in appropriate units e.g. KB, MB, GB, TB e.g. 23446 B = 22 KB 4578876 B = 4 MB 96435465445 B = 89 GB
Wscript.Echo byteValue(10243576546) 'Outputs 9 GB Function byteValue(val)
mult = 1024 If val > mult Then val = val/mult unit = " KB" If val > mult Then val = val/mult unit = " MB" If val > mult Then val = val/mult unit = " GB" If val > mult Then val = val/mult unit = " TB" End If End If End If End If byteValue = int(val) & unit End function
Please note that a disclaimer applies to any code on this page.
|