Does anyone know the conversion of KB to mb? thanks
Printable View
Does anyone know the conversion of KB to mb? thanks
1024Kb in an Mb
so to convert multiply the number of Mb to get the no of Kb
Divide the number of Kb by 1024 to get the number of Mb
If you want to quickly convert Bytes into KB/MB/GB use this code from Vbworld
Use it likeCode: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
Newvar = FormatKB(OldVar)
Here is an example of what Sam Finch said,
Code:FS = FileLen("C:\autoexec.bat") / 1024 'returns 0.5107421875
'If you want to have no decimal, change the / to \
Msgbox FS
Thanks everyone it works great!
be careful
there is an SI version(decimal) and a binary version
SI is one kilobyte is 1,000 bytes
SI is one meg is 1,000 Kb or 1,000,000bytes
SI is one gig is 1,000,000,000 bytes
binary is traditionaly written KiB or MiB or GiB
one KiB is 1024 bytes
one MiB is 1024 KiB
one GiB is 1024 MiB
the problem is what are some utility programs using.
older comuter programs typically use binary but not allways.
This is why marketing is such a big department.
6 GiB is 6.4Gb in SI units Which are you going to buy?
I always like the SI standards but I take exception here. I think that the binary unit is needed simply because of the nature of the computer.
I think money talks, and SI walks