View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Charlie Charlie is offline
external usenet poster
 
Posts: 703
Default Inexplicable problem with function

Why limit yourself to such small values? In Engineering apps we prefer to
use Double Precision:

Function Volume(height As Double, width As Double, depth As Double) As Double

Volume = height * width * depth

End Function

But if you must use Byte inputs for some specific reason, try this

Function Volume(height As Byte, width As Byte, depth As Double) As Double

Volume = CDbl(height) * CDbl(width) * depth

End Function


"Pete Jones" wrote:

Hi everyone,

I've created a function to calculate the volume of tanks we produce. I've
limited the first imputs to bytes but I don't want to limit the last imput.

However when the first two inputs, height and width, multiplied toghether
are more than a byte I get an error. I don't understand why since
individually the inputs are less then byte size.

For eg the following produces an error Volume( 200, 100,500)


Below is the function
Function Volume(height As Byte, width As Byte, depth)

Volume = height * width * depth

End Function

Any help greatly appreciated

Thanks

Peter