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

Example of Find using FindField in Visual Basic

楼主#
更多 发布于:2003-09-03 21:45
Private Sub FindTest_Click()
    Dim fftrFoundObj As mapxlib.FindFeature
    Dim lyrUSA As mapxlib.Layer
    Dim dsFind As mapxlib.Dataset
    
    'add the layer we're going to search in
    Set lyrUSA = Map1.Layers.Add("usa.tab")
    
    'create a dataset from that layer
    Set dsFind = Map1.Datasets.Add(miDataSetLayer, lyrUSA)
    
    'set the layer's FindDataset and FindField
    Set lyrUSA.Find.FindDataset = dsFind
    Set lyrUSA.Find.FindField = dsFind.Fields("State_Name")

    
    'now search the layer
    Set fftrFoundObj = lyrUSA.Find.Search("New York")
    
    'if a good match was found , display that feature,
    'if not display the FindResult code
    If (fftrFoundObj.FindRC Mod 10 = 1) Then
        Map1.Zoom = 500
        Map1.CenterX = fftrFoundObj.CenterX
        Map1.CenterY = fftrFoundObj.CenterY
    Else
        MsgBox "No exact match found. " + Str$(fftrFoundObj.FindRC)
    End If
    
End Sub
喜欢0 评分0
愿意和大家交朋友! QQ:47559983 MSN:shaolun_yuan@hotmail.com eMail:shaolun-yuan@163.com
游客

返回顶部