Hi everybody,
Getting an overflow error that i just can't fathom.
Basically the code takes a string field tbl_Media_Page_Size (e.g. 297 x 210) and strips the left and right numbers into num1 and num2 then tries to multiply them. It always overflows whether I'm using integer, long, single or double and I'm not sure why.
A watch confirms the figures in num1 and num2 are 297 and 210, I can add, divide or minus the number and it works, but it always overflows on a multiplication.
Dim stReadPageSize As String
Dim iPageSize As Long
Dim StringLength As Integer
Dim iPos As Integer
Dim num1 As Integer
Dim num2 As Integer
stReadPageSize = Trim(tbl_Media_Page_Size)
StringLength = Len(stReadPageSize)
iPos = InStr(1, stReadPageSize, "x")
StringLength = (StringLength - iPos)
iPos = iPos - 1
num1 = CInt(Left(stReadPageSize, iPos))
num2 = CInt(Right(stReadPageSize, StringLength))
iPageSize = num1 * num2
MsgBox iPageSize
Any help with this annoying problem is most appreciated.
Thanks,
Jon
Getting an overflow error that i just can't fathom.
Basically the code takes a string field tbl_Media_Page_Size (e.g. 297 x 210) and strips the left and right numbers into num1 and num2 then tries to multiply them. It always overflows whether I'm using integer, long, single or double and I'm not sure why.
A watch confirms the figures in num1 and num2 are 297 and 210, I can add, divide or minus the number and it works, but it always overflows on a multiplication.
Dim stReadPageSize As String
Dim iPageSize As Long
Dim StringLength As Integer
Dim iPos As Integer
Dim num1 As Integer
Dim num2 As Integer
stReadPageSize = Trim(tbl_Media_Page_Size)
StringLength = Len(stReadPageSize)
iPos = InStr(1, stReadPageSize, "x")
StringLength = (StringLength - iPos)
iPos = iPos - 1
num1 = CInt(Left(stReadPageSize, iPos))
num2 = CInt(Right(stReadPageSize, StringLength))
iPageSize = num1 * num2
MsgBox iPageSize
Any help with this annoying problem is most appreciated.
Thanks,
Jon