Results 1 to 6 of 6

Thread: Using kbytes instead of bytes

  1. #1

    Thread Starter
    New Member
    Join Date
    Apr 2000
    Posts
    10
    I want to see what the size of files are on my computer from my program, but I can only show what the size is in bytes. What i would want is to see the size of files in kbytes. Can anyone who knows tell me that?

    Thanx

  2. #2
    Guest
    Multiply the KB by 1000 to get the bytes.


  3. #3
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    1024 i thought.

  4. #4
    Hyperactive Member
    Join Date
    Nov 1999
    Location
    Leavenworth KS USA
    Posts
    482
    *smirk* And, ahem, dividing by 1024 may get even closer.

    {I read it backwards the first time too. That's why I was smirking. Please, No disrespect intended!!! We're all human.}

    [Edited by Mongo on 05-31-2000 at 09:44 PM]

  5. #5
    Guest
    Convert bytes to K or MB:

    Code:
    Dim FileSize1 As String
    Dim FileSize2 As String
    
    'Code:
    Private Function FileSize()
        ' 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
    
    
    
    Private Sub FileSize(ffile)
        ' convert the current file size to different format
        FileSize1 = FileLen(ffile)
        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: " & ffile & vbCrLf & "Old Size: "; FileSize1 & _
              vbCrLf & "New Size: " & FileSize2
        Me.Caption = ffile & " - Size: " & FileSize2
    End Sub

  6. #6
    Guest
    I must have read it wrong (seriously). I thought he wanted to convert KB into Bytes.

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