-
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
-
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
-
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
-
You can't use an Integer! Declare MySize as a Long instead.
(1500000 is to large for an Integer. Max size = 32767)
-
Re: Simple Divison!
Quote:
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
-
Whoops! Fast replys here! :)
I think a Long will be enough if your file isn't bigger then 2Gb.