笑傲江湖dragon
路人甲
路人甲
  • 注册日期2009-05-06
  • 发帖数7
  • QQ
  • 铜币121枚
  • 威望0点
  • 贡献值0点
  • 银元0个
阅读:1573回复:0

关于用mo进行二次开发的问题

楼主#
更多 发布于:2009-05-15 18:17
<P>我在设置代码时,遇到这样的问题“是时错误'91'对象变量或with块变量未设置”代码如下:<BR>Dim r As MapObjects2.Rectangle<BR>Private LastExtent As Rectangle<BR>Private NextExtent As Rectangle<BR>Dim dc As New DataConnection<BR>Dim layer As MapLayer</P>
<P><BR>Private Sub Form_Load()<BR>    Dim col As Object<BR>    dc.Database = "D:\供应链设计大赛\shuju"<BR>    If Not dc.Connect Then<BR>        MsgBox "在指定的文件夹下没有找到图层数据文件!"<BR>        End<BR>    End If<BR>    LayerSet<BR>    legend1.setMapSource Map1<BR>    legend1.LoadLegend True<BR>    Map1.Refresh<BR>    Set col = ListView1.ColumnHeaders.Add()<BR>    col.Text = "属性名称"<BR>    Set col = ListView1.ColumnHeaders.Add()<BR>    col.Text = "属性值"<BR>End Sub<BR>Private Sub legend1_AfterSetLayerVisible(Index As Integer, isVisible As Boolean)<BR>    Map1.Refresh<BR>End Sub</P>
<P>Private Sub Map1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)<BR>    Dim ly As MapObjects2.MapLayer<BR>    Dim fld As MapObjects2.Field<BR>    Dim p As MapObjects2.Point<BR>    Dim newItem As Object<BR>    Dim Recs As MapObjects2.Recordset<BR>    <BR>    If Toolbar1.Buttons(5).Value = 1 Then<BR>        Set Map1.Extent = Map1.TrackRectangle<BR>    ElseIf Toolbar1.Buttons(1).Value = 1 Then<BR>        Set LastExtent = Map1.Extent<BR>        Map1.Pan<BR>    ElseIf Toolbar1.Buttons(6).Value = 1 Then<BR>        Set r = Map1.Extent<BR>        r.ScaleRectangle 1.5<BR>        Map1.Extent = r<BR>    ElseIf Toolbar1.Buttons(7).Value = 1 Then<BR>        Set ly = Map1.Layers("soils")<BR>        Set p = Map1.ToMapPoint(X, Y)<BR>        Set Recs = ly.SearchShape(p, moPointInPolygon, "")<BR>        If Not Recs.EOF Then<BR>            ListView1.ListItems.Clear<BR>            For Each fld In Recs.Fields<BR>                Set newItem = ListView1.ListItems.Add<BR>                newItem.Text = fld.Name<BR>                newItem.SubItems(1) = fld.ValueAsString<BR>            Next fld<BR>        End If<BR>    End If<BR>End Sub</P>
<P>Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)<BR>    If Toolbar1.Buttons(5).Value = 1 Then<BR>        Map1.MousePointer = moZoomIn<BR>    ElseIf Toolbar1.Buttons(1).Value = 1 Then<BR>        Map1.MousePointer = moPan<BR>    ElseIf Toolbar1.Buttons(6).Value = 1 Then<BR>        Map1.MousePointer = moZoomOut<BR>    ElseIf Toolbar1.Buttons(4).Value = 1 Then<BR>        Set Map1.Extent = Map1.FullExtent<BR>    ElseIf Toolbar1.Buttons(2).Value = 1 Then<BR>        If Not LastExtent Is Nothing Then<BR>            Set NextExtent = Map1.Extent<BR>            Set Map1.Extent = LastExtent<BR>            Set LastExtent = Nothing<BR>        End If<BR>    ElseIf Toolbar1.Buttons(3).Value = 1 Then<BR>        If Not NextExtent Is Nothing Then<BR>            Set LastExtent = Map1.Extent<BR>            Set Map1.Extent = NextExtent<BR>            Set NextExtent = Nothing<BR>        End If<BR>         Map1.MousePointer = moDefault<BR>    End If<BR>End Sub<BR>Private Sub LayerSet()<BR>  Dim Sline As Object<BR>  <BR>  Set layer = New MapLayer<BR>  Set layer.GeoDataset = dc.FindGeoDataset("soils")<BR>  layer.Symbol.Color = moLightGray<BR>  layer.Symbol.SymbolType = moLineSymbol<BR>  layer.Symbol.Size = 1<BR>  layer.Symbol.OutlineColor = moBrown<BR>  layer.Name = "土壤"<BR>  Map1.Layers.Add layer</P>
<P>  Set layer = New MapLayer<BR>  Set layer.GeoDataset = dc.FindGeoDataset("Streams")<BR>  layer.Symbol.Color = moBlue<BR>  layer.Name = "河"<BR>  Map1.Layers.Add layer</P>
<P>  Set layer = New MapLayer<BR>  Set layer.GeoDataset = dc.FindGeoDataset("Wells")<BR>  layer.Symbol.Color = moRed<BR>  layer.Symbol.Size = 1<BR>  layer.Symbol.Style = 0<BR>  layer.Name = "水井"<BR>  Map1.Layers.Add layer</P>
<P>End Sub<BR>是在这一句“Set Recs = ly.SearchShape(p, moPointInPolygon, "")<BR>”出现这种问题,希望大家能给我个提示,并且帮忙解答,在这里向大家表示谢谢!!!<BR>还有一个问题想问大家:我在进行二次开发的时候,最后想利用这样的程序进行“最短路径分析”,接下来我不知道怎样调用ArcView中网络分析中最短路径分析的模块?希望大家帮忙解答!!!谢谢啦!!!</P>
喜欢0 评分0
游客

返回顶部