⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form02.frm

📁 一个关于基于MO编程的参考资料希望对大家的交流和学习有帮助
💻 FRM
字号:
VERSION 5.00
Object = "{9BD6A640-CE75-11D1-AF04-204C4F4F5020}#2.0#0"; "mo20.ocx"
Begin VB.Form Form02 
   Caption         =   "世界地图"
   ClientHeight    =   5325
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   8250
   LinkTopic       =   "Form1"
   ScaleHeight     =   5325
   ScaleWidth      =   8250
   StartUpPosition =   3  '窗口缺省
   Begin VB.ListBox List1 
      Height          =   4920
      Left            =   6480
      TabIndex        =   3
      Top             =   120
      Width           =   1695
   End
   Begin VB.CommandButton Command2 
      Caption         =   "Command2"
      Height          =   495
      Left            =   3480
      TabIndex        =   2
      Top             =   4560
      Width           =   1215
   End
   Begin VB.CommandButton Command1 
      Caption         =   "Command1"
      Height          =   495
      Left            =   1680
      TabIndex        =   1
      Top             =   4560
      Width           =   1335
   End
   Begin MapObjects2.Map Map1 
      Height          =   4215
      Left            =   0
      TabIndex        =   0
      Top             =   0
      Width           =   6255
      _Version        =   131072
      _ExtentX        =   11033
      _ExtentY        =   7435
      _StockProps     =   225
      BackColor       =   16777215
      BorderStyle     =   1
      Contents        =   "Form02.frx":0000
   End
End
Attribute VB_Name = "Form02"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'Xuewei,2003/6/18
'用DAO建立和DBF数据库的关联;

Option Explicit

Private Sub Command1_Click()
  Dim fName As String, dName As String
  Dim pTable As New MapObjects2.Table
  Dim Str2 As String
  Dim pLayer As MapObjects2.MapLayer
  Dim pFName As String
  Dim i As Integer
  
  Str2 = App.Path + "\..\world"
  pTable.Database = "dBase IV;DATABASE=" + Str2
  MsgBox pTable.Database
  pTable.Name = "demog"
  Set pLayer = Map1.Layers(0)
  
  'MsgBox "num=" & pTable.Records.TableDesc.FieldName(0)
  MsgBox "num=" & pTable.Records.Count
  
  
  pFName = "FIPS_CODE"    '设置相关字段;
  
  For i = 0 To pTable.Records.TableDesc.FieldCount - 1
    If pTable.Records.TableDesc.FieldName(i) = pFName Then
      '
      pTable.MaxCachedRelateRecords = 100   '设置记录缓冲区大小;
      If pLayer.AddRelate(pFName, pTable, pFName, True) Then
        ListLayers
      Else
        MsgBox "Failed Relate"
      End If
    End If
  Next i
End Sub

Private Sub Command2_Click()
  Map1.Layers(0).RemoveRelates
  ListLayers
End Sub

Private Sub ListLayers()
  Dim pFld As MapObjects2.Field
  Dim Recs As MapObjects2.Recordset
  Dim Layer As MapObjects2.MapLayer
  
  Set Layer = Map1.Layers(0)
  Set Recs = Layer.Records
  MsgBox Recs.Fields("name").Value
  '显示关联后新增记录;
  If Recs.Fields.Count > 18 Then
    MsgBox Recs.Fields("TOT_POP").Value
  End If

  List1.Clear
  For Each pFld In Recs.Fields
    List1.AddItem pFld.Name
  Next pFld
End Sub

Private Sub Form_Load()
  DrawLayer     '加载世界地图country图层;
  ListLayers
  Command1.Caption = "建立关联"
  Command2.Caption = "删除关联"
End Sub

Private Sub DrawLayer()
  Dim dc As New DataConnection
  Dim Layer As MapLayer
  dc.Database = App.Path + "\..\" + "World"
  Set Layer = New MapLayer
  Set Layer.GeoDataset = dc.FindGeoDataset("country")
  Map1.Layers.Add Layer
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -