a general math question....

SDittmar

Newcomer
Joined
Feb 9, 2003
Messages
11
Im trying to convert bytes to kilobytes or megabytes and back again. I have these two functions:

Function DivideTimes(Byval number As Single, iterations As Integer) As Single
Dim x As Integer

For x = 1 to iterations
number /= 1024
Next

Return number

End Function

Function TimesTimes(ByVal number As Single, iterations As Integer) As Single
Dim x As Integer

For x = 1 to iterations
number *= 1024
Next

Return number
End Function

My question is, is there a more efficient way to do these functions? they just seem kinda clunky...
 
To divide:

Visual Basic:
number /= (1024 ^ iterations)

To multiply:

Visual Basic:
number *= (1024 ^ iterations)
 
Back
Top