# Select points in box

**URL:** <https://mapwindow.discourse.group/t/select-points-in-box/1116>\
**Category:** Uncategorized\
**Created:** [October 20, 2021, 1:36pm UTC](https://mapwindow.discourse.group/t/select-points-in-box/1116 "2021-10-20T13:36:41Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mikeradtke](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/mikeradtke/32/558_2.png) [@mikeradtke](https://mapwindow.discourse.group/u/mikeradtke)\
**Post date:** [October 20, 2021, 1:36pm UTC](https://mapwindow.discourse.group/t/select-points-in-box/1116/1 "2021-10-20T13:36:41Z")

</div>

Hello,  
I am trying to select the points in side of the cmselection box but nothing gets selected. I get values returned when i debug.print left, right, bottom and top, but I suspect the problem is that I need to convert these values? Here is my code:

```auto
Private Sub Map0_SelectBoxFinal(ByVal left As Long, ByVal right As Long, ByVal bottom As Long, ByVal top As Long)
Dim gs As New MapWinGIS.GlobalSettings
gs.AllowProjectionMismatch = True
Me.Map0.SendSelectBoxFinal = True
Dim sf As New MapWinGIS.Shapefile
Dim ext As New MapWinGIS.Extents
Dim lh As Integer
Dim xmin As Double
Dim ymin As Double
Dim zmin As Double
Dim xmax As Double
Dim ymax As Double
Dim zmax As Double
Dim i As Long
Dim results As Object

With Me.Map0

xmin = left
ymin = bottom
zmin = 0#
xmax = right
ymax = top
zmax = 0#

ext.SetBounds xmin, ymin, zmin, xmax, ymax, zmax

lh = Me.Map0.LayerHandle(0)

sf.StartEditingShapes (True)

sf.SelectShapes ext, 0#, SelectMode.INTERSECTION, results

For i = 0 To 100
sf.ShapeSelected(i) = True
Next

Debug.Print sf.NumShapes

End With

End Sub

```

---

<div class="post-metadata">

**Author:** ![mikeradtke](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/mikeradtke/32/558_2.png) [@mikeradtke](https://mapwindow.discourse.group/u/mikeradtke)\
**Post date:** [October 20, 2021, 4:31pm UTC](https://mapwindow.discourse.group/t/select-points-in-box/1116/2 "2021-10-20T16:31:24Z")

</div>

Another possible solution is to be able to get the details of the points highlighted with cmselection. I am able to draw a box and have the points within the box highlighted, but I’m not able to interact with the selected points as I am with the cmidentify tool. Any help would be greatly appreciated!

---

<div class="post-metadata">

**Author:** ![mikeradtke](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/mikeradtke/32/558_2.png) [@mikeradtke](https://mapwindow.discourse.group/u/mikeradtke)\
**Post date:** [October 20, 2021, 11:50pm UTC](https://mapwindow.discourse.group/t/select-points-in-box/1116/4 "2021-10-20T23:50:07Z")

</div>

i figured it out. the shapes were being selected, i just needed the correct code to extract the information.

---

<div class="post-metadata">

**Author:** ![pmeems](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/pmeems/32/9_2.png) [@pmeems](https://mapwindow.discourse.group/u/pmeems)\
**Post date:** [January 5, 2022, 11:12am UTC](https://mapwindow.discourse.group/t/select-points-in-box/1116/5 "2022-01-05T11:12:31Z")

</div>

@mikeradtke Great that you solved your own issue.  
Would you mind sharing your working code? It might help others.

---

<div class="post-metadata">

**Author:** ![pmeems](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/pmeems/32/9_2.png) [@pmeems](https://mapwindow.discourse.group/u/pmeems)\
**Post date:** [February 2, 2022, 9:38am UTC](https://mapwindow.discourse.group/t/select-points-in-box/1116/6 "2022-02-02T09:38:06Z")

</div>



---

<div class="post-metadata">

**Author:** ![pmeems](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/pmeems/32/9_2.png) [@pmeems](https://mapwindow.discourse.group/u/pmeems)\
**Post date:** [March 9, 2022, 7:36am UTC](https://mapwindow.discourse.group/t/select-points-in-box/1116/7 "2022-03-09T07:36:59Z")

</div>



---

<div class="post-metadata">

**Author:** ![mikeradtke](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/mikeradtke/32/558_2.png) [@mikeradtke](https://mapwindow.discourse.group/u/mikeradtke)\
**Post date:** [March 9, 2022, 4:30pm UTC](https://mapwindow.discourse.group/t/select-points-in-box/1116/8 "2022-03-09T16:30:22Z")

</div>

Sure! Here it is:

```auto
Me.Map0.SetFocus
Dim gs As New MapWinGIS.GlobalSettings
gs.AllowProjectionMismatch = True
Me.Map0.SendSelectBoxFinal = True

Dim lh As Integer
Dim xmin As Double
Dim ymin As Double
Dim zmin As Double
Dim xmax As Double
Dim ymax As Double
Dim zmax As Double
Dim i As Long
Dim results As Object
Dim ext As New extents
Dim Y As Integer
Dim z As Integer
Dim sf As Shapefile
xmin = Left
ymin = Bottom
zmin = 0#
xmax = Right
ymax = Top
zmax = 0#
mn = DCount("[ID]", "Status")
mx = mn + DMax("lyrlookup", "CSI Divisions") - 1
DoCmd.SetWarnings (False)
DoCmd.RunSQL "DELETE * FROM Emails where [Work State] <> 'Nationwide'"

With Me.Map0
For sb = mn To mx
Set sf = Me.Map0.Shapefile(sb)
If DCount("[shapeno]", "Master", "[Layer] = " & sb) = 0 Then GoTo nxt
ext.SetBounds xmin, ymin, zmin, xmax, ymax, zmax
sf.SelectShapes ext, 0#, SelectMode.INCLUSION, results
Y = DMin("[shapeno]", "Master", "[Layer] = " & sb)
z = DMax("[shapeno]", "Master", "[Layer] = " & sb)
    For i = Y To z
    If sf.ShapeSelected(i) = False Then GoTo nn
    If sf.ShapeSelected(i) = True Then
    subbb = DLookup("[Subcontractor]", "Master", "[shapeno] = " & i & " AND [Layer] = " & sb)

        If IsNull(subbb) Then GoTo nn
        strSQL = "INSERT INTO Emails ([Subcontractor],[Union],[Trade],[Trade 2],[Trade 3],[Trade 4],[Trade 5],[Trade 6],[Division],[Work State],[Rating],[E-mail 1],[E-mail 2],[E-mail 3])" & _
        "SELECT [Subcontractor],[Union/Non Union],[Trade],[Trade2],[Trade3],[Trade4],[Trade5],[Trade6], [CSI Division], [Work State], [Rating],[E-mail 1],[E-mail 2],[E-mail 3] FROM Master" & _
        " WHERE [Subcontractor] = '" & subbb & "'"
        DoCmd.RunSQL strSQL
          
nn:
    End If

sf.ShapeSelected(i) = False
    Next
nxt:
Next
cc:

End With

Me.Map0.CursorMode = cmPan
DoCmd.RunSQL "DELETE * FROM Emails WHERE isnull([E-mail 1])"
If DCount("[ID]", "Emails") = 0 Then
Forms!Jobtemplate.SetFocus
GoTo skpop
End If
DoCmd.OpenForm "MassReviewRecipients", , , , , , Me.Name
skpop:
DoCmd.SetWarnings (True)

Set pr = Nothing
Set rq = Nothing
Set sf = Nothing
Exit Sub

```

---

<div class="post-metadata">

**Author:** ![pmeems](https://yyz2.discourse-cdn.com/free1/user_avatar/mapwindow.discourse.group/pmeems/32/9_2.png) [@pmeems](https://mapwindow.discourse.group/u/pmeems)\
**Post date:** [March 10, 2022, 7:30am UTC](https://mapwindow.discourse.group/t/select-points-in-box/1116/9 "2022-03-10T07:30:15Z")

</div>


