VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Convert Bytes into K, MB, GB

by Alexandre Bianco (2 Submissions)
Category: Files/File Controls/Input/Output
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 18th March 2003
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Convert Bytes into K, MB, GB

Rate Convert Bytes into K, MB, GB



    Dim nBytes
    Dim nBytes2
    Dim nBytesConverted
    nBytes = Val(cBytes / 1024)
    nBytes2 = Val(nBytes / 1024)
    Select Case Len(cBytes)
        Case 1, 2, 3
            'BYTES
            nBytesConverted = cBytes & " Bytes"
        Case 4, 5, 6
            'KILO BYTES
            nBytesConverted = Format((cBytes / 1024), "0.00 K")
        Case Else
            If Len(nBytes2) <= 3 Then
                'MEGA BYTES
                nBytesConverted = Format((nBytes2), "0 MB")
            Else
                'GIGA BYTES
                nBytesConverted = Format((nBytes2 / 1024), "0.00 GB")
            End If
    End Select
    ConvertBytes = nBytesConverted
End Function


Download this snippet    Add to My Saved Code

Convert Bytes into K, MB, GB Comments

No comments have been posted about Convert Bytes into K, MB, GB. Why not be the first to post a comment about Convert Bytes into K, MB, GB.

Post your comment

Subject:
Message:
0/1000 characters