Results 1 to 6 of 6

Thread: Kilobytes to megabytes?

  1. #1

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330

    Question

    Does anyone know the conversion of KB to mb? thanks
    Matt

  2. #2
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    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

  3. #3
    Frenzied Member Jop's Avatar
    Join Date
    Mar 2000
    Location
    Amsterdam, the Netherlands
    Posts
    1,986
    If you want to quickly convert Bytes into KB/MB/GB use this code from Vbworld

    Code:
    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
    Use it like

    Newvar = FormatKB(OldVar)

    Jop - validweb.nl

    Alcohol doesn't solve any problems, but then again, neither does milk.

  4. #4
    Guest
    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

  5. #5

    Thread Starter
    Hyperactive Member MPrestonf12's Avatar
    Join Date
    Jun 1999
    Location
    NY
    Posts
    330

    Thumbs up great!

    Thanks everyone it works great!
    Matt

  6. #6
    Hyperactive Member badgers's Avatar
    Join Date
    Sep 1999
    Location
    Madison, WI USA
    Posts
    444
    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
    I am so skeptical, I can hardly believe it!
    PS I am not a 'hyperactive member' I am a cool, calm, and collected member

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width