vb的实时错误'28' 堆栈空间溢出
做了一个软件前几天还好好的
突然就有问题呢 俺是个新手 彻底没辙了
代码如下 急啊
Private Sub grdFeatList_SelChange()
'Allow the user to interact with the selected features
'displayed in the Grid. Have the user's selections
'trigger other actions like Highlight, InsertPin, Pan, and ZoomTo.
frmFind.grdFeatList.Col = 0
frmFind.grdFeatList.ColSel = 2
If frmFind.grdFeatList.Row > 0 Then
frmFind.cmdHighlight.Enabled = True
frmFind.cmdInsertPin.Enabled = True
frmFind.cmdPanto.Enabled = True
frmFind.cmdZoomto.Enabled = True
Else
frmFind.cmdHighlight.Enabled = False
frmFind.cmdPanto.Enabled = False
frmFind.cmdZoomto.Enabled = False
frmFind.cmdInsertPin.Enabled = False
End If
End Sub
--------------------编程问答-------------------- 据我分析,这段代码是不会造成“堆栈溢出”问题的!
楼主,何以见得就是这段代码造成的呢?
--------------------编程问答-------------------- 我选择调试之后它自动显示的啊
很奇怪
前几天还没有这个问题的
似乎今天就突然出来了
而且怎么都调不回来啊
郁闷
--------------------编程问答-------------------- 要不你加我QQ ??
我具体请教一下
449757848
感谢哈
--------------------编程问答-------------------- 你加个on error goto
把错误定位一下 --------------------编程问答-------------------- 我试试哈
--------------------编程问答-------------------- 那位仁兄能加我QQ具体的指导一下
这样问来问去的
太急人了
拜托 --------------------编程问答-------------------- 关键是要找到出错的地方。
楼主的 grdFeatList 是具体是什么控件?
我刚才试了一下,用的是 MSFlexGrid 表格控件,虽然在 SelChange() 事件有改变当前单元格和选择范围的代码,但它并没有引起“连锁反应”,出现‘堆栈溢出’的错误!
所以,楼主贴出来的代码不是出错的地方!
--------------------编程问答-------------------- 首先感谢哈
但是怎样才能找到错误所在呢?
--------------------编程问答-------------------- 那这段呢??
Private Sub Find_Actions(f_Action As String)
Dim curRec As MapObjects2.Recordset
Dim Rect As Rectangle, Rect2 As Rectangle
Dim curIndex As Integer, aIndex As Integer
Dim aRec As Integer, i As Integer
Dim aName As String
Dim shapeX As Double, shapeY As Double
Dim deltax As Double, deltay As Double
Dim theShape As Object, pinPoint As MapObjects2.Point
'
' Determine selected item from list.
'
curIndex = frmFind.grdFeatList.Row - 1
If IsNull(curIndex) Or curIndex < -1 Then
Exit Sub
End If
aIndex = layerNum(1, curIndex)
aRec = layerNum(2, curIndex)
aName = layerName(aIndex)
'
' Set curRec variable to the correct record.
'
Set curRec = Recs2(aIndex)
curRec.MoveFirst
If aRec > 0 Then
For i = 1 To aRec
curRec.MoveNext
Next i
End If
'
' Perform unique actions based on selected button.
'
Select Case f_Action
Case "cmdHighlight"
frmMain.mapDisp.FlashShape curRec("shape").Value, 3
Case "insert_pin"
Set pinPoint = Nothing
Select Case curRec("shape").Type
Case moPoint
Set pinPoint = curRec("shape").Value
Case moLine
MsgBox "Cannot insert a pin for a line feature"
Case moPolygon
Set pinPoint = curRec("shape").Value.Centroid
End Select
If Not pinPoint Is Nothing Then
frmMain.mapDisp.TrackingLayer.AddEvent pinPoint, frmMain.mapDisp.TrackingLayer.SymbolCount - 1
End If
Case "cmdPanto"
Set Rect2 = frmMain.mapDisp.Extent
Set theShape = curRec("shape").Value
If curRec("shape").Type = moPoint Then
shapeX = curRec("shape").Value.x
shapeY = curRec("shape").Value.y
Else
Set Rect = curRec("shape").Value.Extent
shapeX = Rect.Center.x
shapeY = Rect.Center.y
End If
deltax = shapeX - Rect2.Center.x
deltay = shapeY - Rect2.Center.y
Rect2.Offset deltax, deltay
frmMain.mapDisp.Extent = Rect2
frmMain.mapDisp.Refresh
frmMain.mapDisp.FlashShape theShape, 3
Case "cmdZoomto"
Set theShape = curRec("shape").Value
If curRec("shape").Type = moPoint Then
Set Rect2 = frmMain.mapDisp.Extent
shapeX = curRec("shape").Value.x
shapeY = curRec("shape").Value.y
deltax = shapeX - Rect2.Center.x
deltay = shapeY - Rect2.Center.y
Rect2.Offset deltax, deltay
Rect2.ScaleRectangle 0.1
frmMain.mapDisp.Extent = Rect2
Else
Set Rect = curRec("shape").Value.Extent
Rect.ScaleRectangle 1.1
frmMain.mapDisp.Extent = Rect
End If
frmMain.mapDisp.Refresh
frmMain.mapDisp.FlashShape theShape, 3
End Select
End Sub --------------------编程问答--------------------
KAO!又是数据库..........
①在提示“堆栈溢出”的时候,点“调试”,看清楚它在哪个过程中中断。
②然后把‘当前语句’的箭头拖到 End Sub (或 End Function) 处,也可以用鼠标右击当前过程的 End Sub,在菜单中选“设置下一条语句”。
③按 F8 ,看它返回到哪个过程中。
④重复 ②和③ ,记清楚是哪一个(或者两个、三个或更多个)过程在循环调用。
再分析原因吧。
--------------------编程问答-------------------- 堆栈,一般就是调用过程时要使用,参数入栈,返回地址入栈之类.....
堆栈溢出,多数是产生了循环调用或递归调用,并且层数很深.
按这个思路去找原因吧. --------------------编程问答-------------------- 好的
感谢
我试试哈
嘿嘿 --------------------编程问答--------------------
偶试了一下
都是显示的
If frmFind.grdFeatList.Row > 0 Then
这一句 --------------------编程问答-------------------- 那你把这一句注释掉,直接执行if之后的语句它还溢出么?
补充:VB , 网络编程