Previous Code Entry
Left Arrow
ASP. Classic - How to create a Reusable Replace Function
Current Code Entry
Go Back To Code List
[Forms]
How to convert Bytes into KB and MB and GB and TB
Article Entry Date: August 3,2024 @ 10:59:45 / Last Updated On: August 3,2024 @ 11:03:25
ASP Classic how to convert bytes into KB, MB, GB, and TB.

Original Code from converts.vbs«

The above code gives the following error.
Type mismatch on If Size >= 1024 and on another area, notated below.

If Size >= 1024 Then suffix = " KB"
Needs to be
If CDbl(trim(Size)) >= 1024 Then suffix = " KB"
And
Round(Size)
Needs to be
Round(CDbl(trim(Size)))

So it should look like this.


To use this code, simply wrap your variable like so.
<%=ConvertSize(MyVar)%>