Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Excel / Programming / January 2006

Tip: Looking for answers? Try searching our database.

Overflow error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Grd - 21 Jan 2006 05:14 GMT
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
Tim Williams - 21 Jan 2006 08:13 GMT
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

> Hi,
>
[quoted text clipped - 18 lines]
> Regards
> Janet
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.