Message 1 of 7
Run-Time error 6 - Overflow

Not applicable
04-07-2004
09:37 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I have a VBA application that works fine in Windows NT. When I run it in Windows 95 or Windows XP I get an overflow error.
It appears to happen when I "Get" the property of a class I created and then do some math. A funny thing happened when I began debugging the problem. I wanted to know exactly which "Get" was causing the problem, so I introduced calls to msgbox before doing math calculations with the property values. The dumb thing worked without any errors.
Did slowing it down fix it? Or is something else at work here?
Below are portions of the affected code.
Class:DwgFile
Private m_ScaleFactor As Double
...
Public Property Get ScaleFactor() As Double
ScaleFactor = m_ScaleFactor
End Property
...
Class:Dwgs
Private m_data() As DwgFile
Private m_indx As Integer
Public Sub Add(FilName As String, filpath As String, sf As Double, dType As String, ByVal dSht As DwgSheet)
Dim aDwg As DwgFile
m_indx = m_indx + 1
ReDim Preserve m_data(m_indx)
Set aDwg = New DwgFile
aDwg.FileName = FilName
aDwg.FilePath = filpath
aDwg.ScaleFactor = sf
aDwg.DwgType = dType
Set aDwg.Sheet = dSht
Set m_data(m_indx) = aDwg
End Sub
Public Property Get Item(indx As Integer) As DwgFile
If indx < 0 Or indx > m_indx Then
MsgBox "Invalid index of DwgFiles object", vbCritical
Else
Set Item = m_data(indx)
End If
End Property
...
Calling Procedure:
...
'xref the files
For k = 0 To dwgs.Count - 1
If dwgs.Item(j).DwgType = detSHT Then
adrawing.ActivePViewport.Display True
adrawing.MSpace = True
sf = 1# / dwgs.Item(k).ScaleFactor
Else
MsgBox "Current Drawing: " & dwgs.Item(j).FileName
MsgBox "Numerator: " & dwgs.Item(k).ScaleFactor
MsgBox "Denominator: " & dwgs.Item(j).ScaleFactor
MsgBox "Formula : 1 / (" & dwgs.Item(k).ScaleFactor & "/" & dwgs.Item(j).ScaleFactor & ")"
'Error occurs below if msgbox calls are removed!
sf = 1# / (CDbl(dwgs.Item(k).ScaleFactor) / CDbl(dwgs.Item(j).ScaleFactor))
End If
If dwgs.Item(k).DwgType = detXREF And j <> k Then
fil = tb_path.Value & RenDwgs(k)
xref = Left(RenDwgs(k), Len(RenDwgs(k)) - 4)
Set XrefBlk = adrawing.ModelSpace.AttachExternalReference(fil, xref, _
insPT, sf, sf, sf, 0, True)
XrefBlk.Layer = aLayer.Name
If dwgs.Item(j).DwgType = detXREF Then
If k > 10 Then
clr = 41
Else
clr = colors(k)
End If
Call LyrColor(adrawing, xref, clr)
End If
End If
Next
...
I found similar posting from years ago, but the resolution was apparently accomplished via e-mail.
I'm stumped. Any help would be greatly appreciated.
It appears to happen when I "Get" the property of a class I created and then do some math. A funny thing happened when I began debugging the problem. I wanted to know exactly which "Get" was causing the problem, so I introduced calls to msgbox before doing math calculations with the property values. The dumb thing worked without any errors.
Did slowing it down fix it? Or is something else at work here?
Below are portions of the affected code.
Class:DwgFile
Private m_ScaleFactor As Double
...
Public Property Get ScaleFactor() As Double
ScaleFactor = m_ScaleFactor
End Property
...
Class:Dwgs
Private m_data() As DwgFile
Private m_indx As Integer
Public Sub Add(FilName As String, filpath As String, sf As Double, dType As String, ByVal dSht As DwgSheet)
Dim aDwg As DwgFile
m_indx = m_indx + 1
ReDim Preserve m_data(m_indx)
Set aDwg = New DwgFile
aDwg.FileName = FilName
aDwg.FilePath = filpath
aDwg.ScaleFactor = sf
aDwg.DwgType = dType
Set aDwg.Sheet = dSht
Set m_data(m_indx) = aDwg
End Sub
Public Property Get Item(indx As Integer) As DwgFile
If indx < 0 Or indx > m_indx Then
MsgBox "Invalid index of DwgFiles object", vbCritical
Else
Set Item = m_data(indx)
End If
End Property
...
Calling Procedure:
...
'xref the files
For k = 0 To dwgs.Count - 1
If dwgs.Item(j).DwgType = detSHT Then
adrawing.ActivePViewport.Display True
adrawing.MSpace = True
sf = 1# / dwgs.Item(k).ScaleFactor
Else
MsgBox "Current Drawing: " & dwgs.Item(j).FileName
MsgBox "Numerator: " & dwgs.Item(k).ScaleFactor
MsgBox "Denominator: " & dwgs.Item(j).ScaleFactor
MsgBox "Formula : 1 / (" & dwgs.Item(k).ScaleFactor & "/" & dwgs.Item(j).ScaleFactor & ")"
'Error occurs below if msgbox calls are removed!
sf = 1# / (CDbl(dwgs.Item(k).ScaleFactor) / CDbl(dwgs.Item(j).ScaleFactor))
End If
If dwgs.Item(k).DwgType = detXREF And j <> k Then
fil = tb_path.Value & RenDwgs(k)
xref = Left(RenDwgs(k), Len(RenDwgs(k)) - 4)
Set XrefBlk = adrawing.ModelSpace.AttachExternalReference(fil, xref, _
insPT, sf, sf, sf, 0, True)
XrefBlk.Layer = aLayer.Name
If dwgs.Item(j).DwgType = detXREF Then
If k > 10 Then
clr = 41
Else
clr = colors(k)
End If
Call LyrColor(adrawing, xref, clr)
End If
End If
Next
...
I found similar posting from years ago, but the resolution was apparently accomplished via e-mail.
I'm stumped. Any help would be greatly appreciated.