Code Script .co.uk

Home | Scripts | Tutorials | Disclaimer | Sitemap | Contact

   Convert Byte Value To Kb-mb-gb-tb
 

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.
 
   Actions
  Go Back
  Bookmark
  Print Page


   Menu
 
- Links
- Reference
- Script Editors
- Tutorials
- Vbscript
     - Active Directory
     - Exchange
     - Files And Folders
     - General
     - Ms Office
     - Operating System
     - Processes And Services
     - Text Processing
     - User Interaction
          - Browse For File Dialogue Box
          - Browse For Folder Dialogue Box
          - Convert Byte Value To Kb-mb-gb-tb
          - Copy Text To Clipboard
          - Select Option Popup Dialogue
     - Web Servers