VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Convert Bytes to KB or MB

by CovertLoop (12 Submissions)
Category: Coding Standards
Compatability: Visual Basic 3.0
Difficulty: Beginner
Date Added: Wed 3rd February 2021
Rating: (6 Votes)

This code will enable you to convert bytes to kilobytes or megabytes, whichever you choose. Vote if ya wanna.

Rate Convert Bytes to KB or MB

Private Declare Function StrFormatByteSize Lib _
"shlwapi" Alias "StrFormatByteSizeA" (ByVal _
dw As Long, ByVal pszBuf As String, ByRef _
cchBuf As Long) As String
Public Function FormatKB(ByVal Amount As Long) _
As String
Dim Buffer As String
Dim Result As String
Buffer = Space$(255)
Result = StrFormatByteSize(Amount, Buffer, _
Len(Buffer))
If InStr(Result, vbNullChar) > 1 Then
FormatKB = Left$(Result, InStr(Result, _
vbNullChar) - 1)
End If
End Function

Download this snippet    Add to My Saved Code

Convert Bytes to KB or MB Comments

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

Post your comment

Subject:
Message:
0/1000 characters