发生了'System.OverflowException'类型的未处理异常

时间:2016-03-31 23:33:07

标签: vb.net

我在调用此函数时遇到错误“在”

中发生了'System.OverflowException'类型的未处理异常
Public Structure GlowStruct
    Public r As Single
    Public g As Single
    Public b As Single
    Public a As Single
    Public rwo As Boolean
    Public rwuo As Boolean
End Structure

Private Sub DrawGlow(ByVal pGlowIn As Int32, ByVal col As GlowStruct)
    Dim pGlowObj = Mem.ReadInt(bClient + Offset.oGlowObject, 4)
    Mem.WriteSingle(pGlowObj + ((pGlowIn * &H38) + &H4), 4, col.r)
    Mem.WriteSingle(pGlowObj + ((pGlowIn * &H38) + &H8), 4, col.g)
    Mem.WriteSingle(pGlowObj + ((pGlowIn * &H38) + &HC), 4, col.b)
    Mem.WriteSingle(pGlowObj + ((pGlowIn * &H38) + &H10), 4, col.a)
    Mem.WriteBool(pGlowObj + ((pGlowIn * &H38) + &H24), 1, col.rwo)
    Mem.WriteBool(pGlowObj + ((pGlowIn * &H38) + &H25), 1, col.rwuo)
End Sub

1 个答案:

答案 0 :(得分:1)

当你将pGlowObj相乘时,它仍被视为整数。据推测,pGlowObj *& H38超过了整数的最大值。

因为你无论如何都要在计算结束时使用Single,只需强制pGlowObj作为单个开始,然后它就不会溢出:

Dim pGlowObj as Single = Mem.ReadInt(bClient + Offset.oGlowObject, 4)