在WhereClause for ArcGis中使用列表框中的多个选定项目

时间:2014-12-23 13:34:29

标签: vb.net listbox arcgis

我可以使用WhereClause在ArcGis中选择一个选定的项目。目前,我正在选择多个项目,并使用这些选定项目编写WhereClause。

我的问题是:如何使用多个项目构建WhereClause。要么;如何使用多个选定项目填充msgbox? multipleclause是我想要循环的变量,直到所有项目都被使用。

    Dim count As Integer = 0
    count = ListBox3.SelectedItems.Count
    If count = 0 Then
        MsgBox("Geen features geselecteerd")

    ElseIf count = 1 Then
        result = veld & "= '" & waarde & "'"
        MsgBox(result)

    Else
        firstclause = veld & "= '" & waarde & "'"
        For Each waarde In ListBox3.SelectedItems
            Do Until waarde Is Nothing
                multipleclause = " OR " & veld & "= '" & waarde & "'"
            Loop
        Next

        result = firstclause & multipleclause
        MsgBox(result)

    End If

1 个答案:

答案 0 :(得分:0)

这应该让你入门

Dim count As Integer = 0
count = ListBox3.SelectedItems.Count
If count = 0 Then
    MsgBox("Geen features geselecteerd")

ElseIf count = 1 Then
    result = veld & "= '" & waarde & "'"
    MsgBox(result)

Else
    Dim sb as new System.Text.StringBuilder
    dim bFirst as Boolean = True
    For Each waarde In ListBox3.SelectedItems
        if bFirst Then
            bFirst = False
        else
            sb.append(" OR ")
        End If
        sb.Append(veld & "= '" & waarde & "'")
    Next

    result = sb.tostring
    MsgBox(result)

End If