VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Convert Bytes into K or MB

by Alex Rohr (2 Submissions)
Category: Files/File Controls/Input/Output
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Mon 14th June 1999
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Convert Bytes into K or MB

API Declarations


Dim FileSize2 As String

Rate Convert Bytes into K or MB



    ' convert the current file size to different format
    Static xx
    FileSize1 = FileLen(File1.Path & "\" & File1.List(0))
    xx = FileSize1 / 1024
    If Len(FileSize1) >= 7 Then
        FileSize2 = Format((xx / 1024), "0.00")
        FileSize2 = FileSize2 & " MB"
    ElseIf Len(FileSize1) >= 4 Then
        xx = Format((FileSize1 / 1024), "0.00")
        FileSize2 = xx & " K"
    Else
        FileSize2 = FileSize1 & " Bytes"
    End If
    Debug.Print "File: " & File1.List(0) & vbCrLf & "Old Size: "; FileSize1 & _
          vbCrLf & "New Size: " & FileSize2
    Me.Caption = File1.List(0) & " - Size: " & FileSize2
End Function


Download this snippet    Add to My Saved Code

Convert Bytes into K or MB Comments

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

Post your comment

Subject:
Message:
0/1000 characters