袁绍伦
路人甲
路人甲
  • 注册日期2003-08-08
  • 发帖数654
  • QQ164646905
  • 铜币1336枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1157回复:0

Example in Visual Basic

楼主#
更多 发布于:2003-09-03 21:44
Public Sub SearchEx(txtCity As String, txtState As String)
Dim lyrCity As Layer
Dim dsCity As Dataset
Dim dsState As Dataset
Dim objFindResult As FindResult
Dim intNumCols As Integer
Dim intNumRows As Integer
Dim counter As Integer
Dim firstcounter As Integer

' This file ships as sample data with MapX.
Set lyrCity = Map1.Layers("US Minor Cities")  
Set lyrState = Map1.Layers("USA")
'    Add the datasets
Set dsCity = Map1.Datasets.Add(miDataSetLayer, lyrCity)

Set dsState = Map1.Datasets.Add(miDataSetLayer, lyrState)
'    Set the city dataset to be the find dataset
Set lyrCity.Find.FindDataset = dsCity
Set lyrCity.Find.FindField = dsCity.Fields("city")
'    Set the state dataset to be the refining dataset
Set lyrCity.Find.RefineLayer = lyrState
Set lyrCity.Find.RefineDataset = dsState
Set lyrCity.Find.RefineField = dsState.Fields("state")

Set objFindResult = lyrCity.Find.SearchEx(txtCity, txtState)

If objFindResult.MultipleMatches = True Then

 For Each objMatchCandidate In objFindResult.Matches
  firstcounter = firstcounter + 1
  List1.AddItem objMatchCandidate.Name

  intNumRows = objFindResult.Matches.Count
  intNumCols = dsCity.Fields.Count
  CityGrid.Cols = intNumCols
  CityGrid.Rows = intNumRows
  For counter = 1 To intNumCols
   CityGrid.Row = firstcounter - 1
   CityGrid.Col = counter - 1
   CityGrid.Text = dsCity.Value(objMatchCandidate.FeatureID,
   counter)
  Next
 Next
Else
 List1.AddItem objFindResult.MatchedFeature.Name

 intNumCols = dsCity.Fields.Count
 CityGrid.Cols = intNumCols

 For counter = 1 To intNumCols
  CityGrid.Col = counter - 1
  CityGrid.Text = dsCity.Value(
  objFindResult.MatchedFeature.FeatureID, counter)
 Next
End If

End Sub

喜欢0 评分0
愿意和大家交朋友! QQ:47559983 MSN:shaolun_yuan@hotmail.com eMail:shaolun-yuan@163.com
游客

返回顶部