Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi,
I've created a simple funcion to calculate the volume based on three inputs, height, width and depth. I've make the variables bytes. When the result of the volume is over 255 I get an overflow error. See the function below: Function volume(height As Byte, width As Byte, depth As Byte) volume = height * width * depth End Function -------------------------- Sub test() Debug.Print volume(12, 22, 1) End Sub Can anyone help with why I'm getting the error. Thanks in advance Regards Janet |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
You should specifiy the datatype of the return value, and maybe also dim
your parameters as integer. The error is because your multiplication is producing a value too large for the variable's size. Tim "Grd" wrote in message ... Hi, I've created a simple funcion to calculate the volume based on three inputs, height, width and depth. I've make the variables bytes. When the result of the volume is over 255 I get an overflow error. See the function below: Function volume(height As Byte, width As Byte, depth As Byte) volume = height * width * depth End Function -------------------------- Sub test() Debug.Print volume(12, 22, 1) End Sub Can anyone help with why I'm getting the error. Thanks in advance Regards Janet |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Overflow error.. why? | Excel Discussion (Misc queries) | |||
Overflow Error | Excel Programming | |||
Overflow error | Excel Programming | |||
Help! Overflow Error 6 | Excel Programming | |||
overflow error | Excel Programming |