阅读:3797回复:10
请教 vb+mapx 的问题!谢谢!
下面这段代码不知道为什么不能完成预定的功能.请高手帮忙解答一下,谢谢!!
'下面的程序段可以正常运行,但是没有达到预期的效果,为什么不能删除我想要删除的图元呢? '要删除图元,请使用 Layer.DeleteFeature 方法。图元及表示它的行将立即从 MapInfo 表中删除。 ' delete all selected features from the USA layer Dim obj As MapXLib.Feature Dim selectedFtrs As MapXLib.Features Dim lyr As MapXLib.Layer Set lyr = Map1.Layers(1) Set selectedFtrs = lyr.Selection For Each obj In selectedFtrs If obj.Name = "Some Text" Then lyr.DeleteFeature (obj) End If Next |
|
|
1楼#
发布于:2003-08-24 12:05
这段代码也有问题!!
Dim fr As Feature '错误 Dim frs As Features Set frs = Map1.Layers(1).SearchAtPoint(-96.688486, 40.81641) '类型不匹配 Set frs = Map1.Layers(1).SearchAtPoint((-96.688486, 40.81641)) '语法错误 For Each fr In frs MsgBox fr.Name Next |
|
|
2楼#
发布于:2003-08-24 12:05
'此 Visual Basic 示例显示 Parts 集合和 Points 集合如何循环显示所选图元中的所有点。
Dim obj As MapXLib.Feature Dim pts As New Points Dim pt As New Point Set obj = Map1.Layers(1).Selection(1) For Each pts In obj.Parts For Each pt In pts Debug.Print pt.X, pt.Y Next Next |
|
|
3楼#
发布于:2003-08-24 12:05
''''''动态图层事例 '要求对象 函数或子过程未定义
Set Map.Layers.AnimationLayer = Layers(3) For Each lyr In Map.Layers If Map.Layers.AnimationLayer = lyr Then Form1.Show Form1.Print "haha" End If Next |
|
|
4楼#
发布于:2003-08-24 12:06
Dim DS As Object ' workspaces 函数或子程序 未定义
Dim DB As Object ' 难道这个不是系统提供的吗? Dim RS As Object Dim Temp As Object Set DB = Workspaces(0).OpenDatabase("Mapstats.mdb") Set RS = DB.OpenRecordset("USA") Set DS = Map1.DataSets.Add(miDataSetDAO, RS) Set Map1.Layers("usa").LabelProperties.Dataset = DS Set Temp = DS.Fields("GEONAME") Set Map1.Layers("usa").LabelProperties.DataField = Tem |
|
|
5楼#
发布于:2003-08-24 12:06
下面的代码段在Layers 集合中按索引循环。检查集合中的每个Layer 对象并确定图层中显示
的图元的类型? Dim i As Integer For i = 1 To Map1.Layers.Count Select Case Map1.Layers(i).PredominantFeatureType Case miFeatureTypeRegion MsgBox "Layer " & lyr.Name & " contains regions" Case miFeatureTypeLine MsgBox "Layer " & lyr.Name & " contains lines" Case miFeatureTypeSymbol MsgBox "Layer " & lyr.Name & " contains symbols" Case miFeatureTypeMixed MsgBox "Layer " & lyr.Name & "contains mixed _ features" Case miFeatureTypeUnknown MsgBox "Layer " & lyr.Name & " contains unknown Features """ Case miFeatureTypeText MsgBox "Layer " & lyr.Name & "contains text features" End Select Next |
|
|
6楼#
发布于:2003-08-24 12:06
' Dim s As MapXLib.Style '该语句块有问题!
' s.PickRegion ' Set Map1.Layers(1).Style = s |
|
|
7楼#
发布于:2003-08-24 12:06
' Dim lyr As Layer '就是图层的名称! 那么:如何修改一个图层的名称呢!!
' Set lyr = Map1.Layers(2) ' Form1.Show ' Form1.Print lyr '如何修改以有的图层的名称呢? ' Set lyr = Map1.Layers.Item("US major cities") '只能设置为已经存在了的图层名称,但是,这个方法不能修改图层的名称! |
|
|
8楼#
发布于:2003-08-24 12:07
' Dim sfile As Layer '该语句有问题:不懂 with 语句的用法;另外,为什么出错??
' With dlgcommondialog ' .DialogTitle = "add layer" ' .Filter = "mapinfo tables(*.tab)|*.tab" ' .ShowOpen ' If Len(.FileName) = 0 Then ' Exit Sub ' End If ' sfile = .FileName ' End With ' On Error Resume Next ' Map1.Layers.Add sfile |
|
|
9楼#
发布于:2003-08-24 12:08
上面的代码都有问题,他们之间没有关系,没有联系,各个都是独立,请各位高手帮帮这只菜鸟吧!!
万分感谢!!!! |
|
|
上一页
下一页