[Solved] Why does this multiplication cause an OverflowException?


I’m guessing that tsidx and StreamDataBlockSize are Integer types. The largest number an Integer type can hold is 2,147,483,647. The multiplication in brackets is then done expecting an integer result, but the answer is out of the range of Integer types. Change your code to ..

Dim position As Long = hisFileHeader.StreamStartDataPosition + (CLng(TSIdx) * hisFileHeader.StreamDataBlockSize)

and the multiplication will be done with the expectation of a Long type.

2

solved Why does this multiplication cause an OverflowException?