This code converts the filesize in a number to string format?for instance, 1000 Bytes, 1 KB, etc.
Option Explicit' Add a module and copy paste this function.' To test this function, call this function from Immediate window by passing' file size to it. e.g. ?GetFileSizeString(1000), GetFileSizeString(10000)Private Declare Function StrFormatByteSize Lib "shlwapi.dll" Alias "StrFormatByteSizeA" _(ByVal dw As Long, ByVal szBuf As String, ByVal uiBufSize As Long) As LongPrivate Function GetFileSizeString(ByVal lngFileSize As Long) As String Dim strBuff As String strBuff = Space$(100) StrFormatByteSize lngFileSize, strBuff, Len(strBuff) GetFileSizeString = Replace(Trim$(strBuff), vbNullChar, "")End Function
Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.























