Results 1 to 6 of 6

Thread: Simple Divison!

  1. #1

    Thread Starter
    Fanatic Member stickman373's Avatar
    Join Date
    Mar 2001
    Location
    MA
    Posts
    909

    Simple Divison!

    This i s what i need. I open a file using common dialog and then load in text box. I get the file size in bytes using filelen() and then i need to divide the filelen by 1500000 bytes and then add 1 to that number how would i do that?

    mysize / 1500000 + 1 doesn't work ?

    Code:
    Private Sub Command1_Click()
    cd1.Filter = "All Files|*.*"
    cd1.ShowOpen
    Text1.Text = cd1.FileName
    End Sub
    
    Private Sub Command2_Click()
    Dim MySize As Integer
    Dim Accounts
    If Text1.Text = "" Then
    MsgBox ("Please Load File First :-)!")
    Else
    MySize = FileLen(cd1.FileName)
    mysize / 1500000 + 1
    End If
    End Sub

  2. #2
    Lively Member
    Join Date
    May 2001
    Location
    Akureyri, Iceland
    Posts
    69
    An Integer is a number from -32,768 to 32,767.

    You need a Long which is a number from -2,147,483,648 to 2,147,483,647

    That is:
    Dim MySize As Long

  3. #3
    Lively Member
    Join Date
    May 2001
    Location
    Akureyri, Iceland
    Posts
    69
    You could also use Double which is from
    -1.79769313486232E308 to
    -4.94065645841247E-324 for negative values; 4.94065645841247E-324 to 1.79769313486232E308 for positive values

  4. #4
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    You can't use an Integer! Declare MySize as a Long instead.
    (1500000 is to large for an Integer. Max size = 32767)

  5. #5
    Hyperactive Member
    Join Date
    Jul 2001
    Location
    FL
    Posts
    258

    Re: Simple Divison!

    Originally posted by stickman373


    mysize / 1500000 + 1 doesn't work ?

    Code:
    Private Sub Command1_Click()
    cd1.Filter = "All Files|*.*"
    cd1.ShowOpen
    Text1.Text = cd1.FileName
    End Sub
    
    Private Sub Command2_Click()
    Dim MySize As Integer
    Dim Accounts
    If Text1.Text = "" Then
    MsgBox ("Please Load File First :-)!")
    Else
    MySize = FileLen(cd1.FileName)
    mysize / 1500000 + 1
    End If
    End Sub

    I don't know what you are using Accounts for but how about...

    Dim Accounts as Long

    Accounts = MySize / 1500000 + 1

    Thats right too big for an int

  6. #6
    I'm about to be a PowerPoster! Joacim Andersson's Avatar
    Join Date
    Jan 1999
    Location
    Sweden
    Posts
    14,649
    Whoops! Fast replys here!
    I think a Long will be enough if your file isn't bigger then 2Gb.

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