主题:VB代码改错
各位大侠,下面一段代码,运行提示斜线那句是出错的,怎么修改,请多多指教
Private Sub CommandButton1_Click()
Dim strName As String
Dim strAddress As String
Dim pQueryFilter As IQueryFilter
Dim strSQL As String
Dim i As Integer
Dim pFeatureLayer As IFeatureLayer
Dim pEnumLayer As IEnumLayer
Dim pId As New UID
Dim pFeatureCursor As IFeatureCursor
Dim pFeature As IFeature
Dim pFeatureCopy As IFeature '用于直接定位
'查询条件
strName = Trim(TextBox1.Text)
strAddress = Trim(TextBox2.Text)
If strName = "" And strAddress = "" Then
MsgBox "请输入查询条件", vbInformation, "提示"
Exit Sub
End If
If strName <> "" Then
strSQL = "名称 like '%" & strName & "%'"
End If
If strAddress <> "" Then
If strSQL <> "" Then
strSQL = strSQL & " and 地址 like '%" & strAddress & "%'"
Else
strSQL = "地址 like '%" & strAddress & "%'"
End If
End If
Set pQueryFilter = New QueryFilter
pId = "{40A9E885-5533-11D0-98BE-00805F7CED21}"
Set pEnumLayer = pMap.Layers(pId, True)
pEnumLayer.Reset
Set pFeatureLayer = pEnumLayer.Next
Do While Not pFeatureLayer Is Nothing
pQueryFilter.WhereClause = strSQL
[b][i] Set pFeatureCursor = pFeatureLayer.Search(pQueryFilter, False)[/i][/b]
If Not pFeatureCursor Is Nothing Then
Set pFeature = pFeatureCursor.NextFeature
Set pFeatureCopy = pFeature
'检测查询数据
Do While Not pFeature Is Nothing
nObject = nObject + 1
Set pFeature = pFeatureCursor.NextFeature
Loop
MsgBox "查到的对象总数是:" & nObject
Exit Do
End If
Set pFeatureLayer = pEnumLayer.Next
Loop
End Sub