做了一个软件
前几天还好好的
突然就有问题呢 俺是个新手 彻底没辙了代码如下 急啊
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
前几天还好好的
突然就有问题呢 俺是个新手 彻底没辙了代码如下 急啊
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
我刚才试了一下,用的是 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 SelectEnd Sub
②然后把‘当前语句’的箭头拖到 End Sub (或 End Function) 处,也可以用鼠标右击当前过程的 End Sub,在菜单中选“设置下一条语句”。
③按 F8 ,看它返回到哪个过程中。
④重复 ②和③ ,记清楚是哪一个(或者两个、三个或更多个)过程在循环调用。
再分析原因吧。
偶试了一下
都是显示的
If frmFind.grdFeatList.Row > 0 Then
这一句