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

📄 sample vba code.mht

📁 ao的一些代码集合
💻 MHT
📖 第 1 页 / 共 5 页
字号:
      <H3>&#25552;&#31034;</H3>
      <UL>
        =
<LI>&#35831;&#30830;&#23450;VB&#20013;&#30340;&#20195;&#30721;&#26159;&#2=
0197;&#20197;&#19978;&#27493;&#39588;&#20013;&#30340;&#26684;&#24335;&#20=
986;&#29616;&#12290;&#20363;&#22914;&#65292;&#20320;&#21487;&#33021;&#386=
56;&#35201;&#33258;&#24049;&#21152;&#20123;&#22238;&#36710;&#12290; =
</LI></UL>
      <P class=3DBreak></P>
      <P></P></TD></TR></TBODY></TABLE></DIV>
<DIV class=3Dsubhead id=3DhowSub6><A name=3DhowSub6Anchor></A>
<H3><A onclick=3D"expandIt('howSub6')"=20
href=3D"file:///C:/Documents%20and%20Settings/YAZI/&#26700;&#38754;/Dechm=
s/&#23450;&#21046;ArcMap&#21644;ArcCatalog/sample_vba_code.htm#howSub6Anc=
hor"><IMG=20
height=3D11 alt=3D"expand/collapse item"=20
src=3D"file:///C:/Documents%20and%20Settings/YAZI/&#26700;&#38754;/Dechms=
/customizing_arcmap_and_arccatalog/small_arrow_up.gif"=20
width=3D11 border=3D0 name=3DimEx></A> =
&#20197;&#20004;&#20301;&#23567;&#25968;&#30340;&#31934;&#24230;&#26174;&=
#31034;&#40736;&#26631;&#20301;&#32622;</H3></DIV>
<DIV class=3Dsubcontent id=3DhowSub6Content>
<H3>&#25551;&#36848;</H3>
<P class=3DBreak></P>
<P></P>&#26412;&#20363;&#26159;&#29992;&#25143;&#33021;&#22815;&#30475;&#=
35265;&#40736;&#26631;&#25152;&#22312;&#20301;&#32622;&#30340;&#22352;&#2=
6631;&#65292;&#20445;&#30041;&#20004;&#20301;&#23567;&#25968;&#12290;=20
<P class=3DBreak></P><SPAN =
class=3DBreak>&#22312;&#26412;&#20363;&#23376;&#20013;&#65292;&#20320;&#2=
3558;&#28155;&#21152;&#19968;&#20010;&#25353;&#38062;&#24182;&#20026;&#23=
427;&#32534;&#20889;&#20195;&#30721;&#12290;</SPAN>=20
<P class=3DBreak></P>
<P></P>
<H3>How to use</H3>
<P class=3DBreak></P>
<P></P>
<OL>
  <LI>&#21551;&#21160;ArcMap.=20
  <P class=3DBreak></P>
  <P class=3DBreak></P>
  =
<LI>&#25171;&#24320;&#19968;&#20010;&#29616;&#23384;&#30340;&#22320;&#222=
70;&#25991;&#20214;&#65288;.mxd&#65289;&#65292;&#25110;&#23558;&#22270;&#=
23618;&#28155;&#21152;&#21040;&#31354;&#30333;&#30340;&#22320;&#22270;&#2=
5991;&#20214;&#12290;=20
  <P class=3DBreak></P>
  <LI>=93Tools=94&#33756;&#21333;--&gt;=93Customize=94&#12290;=20
  <P class=3DBreak></P>
  <LI>&#28857;&#20987;=93Commands=94&#26631;&#31614;&#12290;=20
  <P class=3DBreak></P>
  =
<LI>&#28857;&#20987;=93Save=94&#32452;&#21512;&#26694;&#26049;&#30340;&#1=
9979;&#31661;&#22836;&#65292;&#24182;&#36873;&#25321;&#26032;&#21629;&#20=
196;&#23558;&#35201;&#20445;&#23384;&#30340;&#22320;&#22270;&#12290;=20
  <P class=3DBreak></P>
  =
<LI>&#28378;&#21160;=93&#31867;&#21035;=94&#21015;&#34920;&#26694;&#65292=
;&#28857;&#20987;=93UIControls=94&#12290;=20
  <P class=3DBreak></P>
  <LI>&#28857;&#20987;=93New UIControl=94&#12290;=20
  <P class=3DBreak></P>
  =
<LI>&#28857;&#20987;UIToolControl&#20316;&#20026;UIControl&#30340;&#31867=
;&#22411;&#12290;=20
  <P class=3DBreak></P>
  =
<LI>&#28857;&#20987;=93&#21019;&#24314;&#24182;&#32534;&#36753;=94&#65292=
;&#25171;&#24320;VB&#32534;&#36753;&#22120;&#12290;=20
  <P class=3DBreak></P>
  =
<LI>&#22797;&#21046;&#20197;&#19979;&#20195;&#30721;&#24182;&#31896;&#361=
48;&#20195;&#30721;&#31383;&#21475;&#20013;&#12290;=20
  <P class=3DBreak></P>
  <P></P>
  <P></P><PRE class=3Dcode><CODE>Private Sub =
UIToolControl1_MouseDown(ByVal button As Long, ByVal shift As Long, =
ByVal x As Long, ByVal y As Long)

  Dim pMxDoc As IMxDocument
  Dim pPoint As IPoint
  Dim pClone As IClone
  Dim pGeometry As IGeometry
  Dim pSpatialRefFactory As ISpatialReferenceFactory
  Dim pSpatialRef As ISpatialReference
  Dim pGeographicCoordSys As IGeographicCoordinateSystem

  'Get the point where the user clicked
  Set pMxDoc =3D Application.Document
  If pMxDoc.CurrentLocation.IsEmpty Then Exit Sub
  'Clone the point because we don't want to alter
  'the actual document's current location point
  Set pClone =3D pMxDoc.CurrentLocation
  Set pPoint =3D pClone.Clone
  Set pGeometry =3D pPoint 'QI

  'Create a new geographic coordinate system to use in the conversion
  Set pSpatialRefFactory =3D New SpatialReferenceEnvironment
  Set pGeographicCoordSys =3D =
pSpatialRefFactory.CreateGeographicCoordinateSystem(esriSRGeoCS_NAD1983)
  Set pSpatialRef =3D pGeographicCoordSys 'QI
  pSpatialRef.SetFalseOriginAndUnits -180, -90, 1000000

  pGeometry.Project pSpatialRef
  MsgBox pPoint.x &amp; ", " &amp; pPoint.y, , "Decimal Degrees"

End Sub</CODE></PRE><BR>
  <P class=3DBreak></P>
  <P></P>
  =
<LI>&#20851;&#38381;&#25110;&#26368;&#23567;&#21270;VB&#31383;&#21475;&#1=
2290;=20
  <P class=3DBreak></P>
  <LI>&#22312;ArcMap&#20013;&#65292;"Tools"--&gt;"Customize"&#12290;=20
  <P class=3DBreak></P>
  <LI>&#28857;&#20987;=93Commands=94&#26631;&#31614;&#12290;=20
  <P class=3DBreak></P>
  =
<LI>&#28857;&#20987;=93Save=94&#32452;&#21512;&#26694;&#26049;&#30340;&#1=
9979;&#31661;&#22836;&#65292;&#24182;&#36873;&#25321;&#26032;&#21629;&#20=
196;&#23558;&#35201;&#20445;&#23384;&#30340;&#22320;&#22270;&#12290;=20
  <P class=3DBreak></P>
  =
<LI>&#28378;&#21160;=93&#31867;&#21035;=94&#21015;&#34920;&#26694;&#65292=
;&#28857;&#20987;=93UIControls=94&#12290;=20
  <P class=3DBreak></P>
  =
<LI>&#23558;=93Commands=94&#21015;&#34920;&#26694;&#20013;&#26032;&#24314=
;&#30340;=93Project.UIToolControl1=94&#25302;&#21160;&#21040;&#20219;&#24=
847;&#24037;&#20855;&#26639;&#19978;&#12290;=20
  <P class=3DBreak></P>
  <LI>&#28857;&#20987;"Close"&#12290;=20
  <P class=3DBreak></P>
  =
<LI>&#28857;&#20987;&#26032;&#24314;&#30340;&#24037;&#20855;&#25353;&#380=
62;&#65292;&#24182;&#22312;&#31383;&#21475;&#30340;&#20219;&#24847;&#2030=
1;&#32622;&#28857;&#20987;&#12290; </LI></OL>
<P class=3DBreak></P>
<P></P>
<TABLE cellPadding=3D5 width=3D"85%" border=3D0>
  <TBODY>
  <TR>
    <TD>
      <H3>&#25552;&#31034;</H3>
      <UL>
        =
<LI>&#35831;&#30830;&#23450;VB&#20013;&#30340;&#20195;&#30721;&#26159;&#2=
0197;&#20197;&#19978;&#27493;&#39588;&#20013;&#30340;&#26684;&#24335;&#20=
986;&#29616;&#12290;&#20363;&#22914;&#65292;&#20320;&#21487;&#33021;&#386=
56;&#35201;&#33258;&#24049;&#21152;&#20123;&#22238;&#36710;&#12290; =
</LI></UL>
      <P class=3DBreak></P>
      <P class=3DBreak></P>
      <P></P></TD></TR></TBODY></TABLE></DIV>
<DIV class=3Dsubhead id=3DhowSub7><A name=3DhowSub7Anchor></A>
<H3><A onclick=3D"expandIt('howSub7')"=20
href=3D"file:///C:/Documents%20and%20Settings/YAZI/&#26700;&#38754;/Dechm=
s/&#23450;&#21046;ArcMap&#21644;ArcCatalog/sample_vba_code.htm#howSub7Anc=
hor"><IMG=20
height=3D11 alt=3D"expand/collapse item"=20
src=3D"file:///C:/Documents%20and%20Settings/YAZI/&#26700;&#38754;/Dechms=
/customizing_arcmap_and_arccatalog/small_arrow_up.gif"=20
width=3D11 border=3D0 name=3DimEx></A> =
&#22312;&#29366;&#24577;&#26639;&#20013;&#26174;&#31034;&#26629;&#26684;&=
#20687;&#20803;&#20540;</H3></DIV>
<DIV class=3Dsubcontent id=3DhowSub7Content>
<P></P>
<H3>&#25551;&#36848;</H3>
<P class=3DBreak></P>
<P></P>&#26412;&#20363;&#26174;&#31034;&#22320;&#22270;&#20013;&#26368;&#=
19978;&#38754;&#30340;&#26629;&#26684;&#22270;&#23618;&#30340;&#20687;&#2=
0803;&#20540;&#12290;&#21487;&#20197;&#26174;&#31034;&#21333;&#27874;&#27=
573;&#25110;&#22810;&#27874;&#27573;&#30340;&#26629;&#26684;&#20687;&#208=
03;&#20540;&#12290;&#36825;&#20123;&#20540;&#26159;&#20197;&#29992;&#2514=
3;&#22312;&#26629;&#26684;&#22270;&#23618;&#19978;&#31227;&#21160;&#40736=
;&#26631;&#26102;&#30340;&#25351;&#38024;&#20301;&#32622;&#30830;&#23450;=
&#30340;&#12290;=20
&#20540;&#23558;&#22312;ArcMap&#31383;&#21475;&#30340;&#24038;&#19979;&#3=
5282;&#26174;&#31034;&#12290;=20
<P class=3DBreak></P><SPAN =
class=3DBreak>&#22312;&#26412;&#20363;&#23376;&#20013;&#65292;&#20320;&#2=
3558;&#28155;&#21152;&#19968;&#20010;&#25353;&#38062;&#24182;&#20026;&#23=
427;&#32534;&#20889;&#20195;&#30721;&#12290;</SPAN>=20
<P class=3DBreak></P>
<P></P>
<H3>&#22914;&#20309;&#25805;&#20316;</H3>
<P class=3DBreak></P>
<OL>
  <LI>&#21551;&#21160;ArcMap.=20
  <P class=3DBreak></P>
  <P class=3DBreak></P>
  =
<LI>&#25171;&#24320;&#19968;&#20010;&#29616;&#23384;&#30340;&#22320;&#222=
70;&#25991;&#20214;&#65288;.mxd&#65289;&#65292;&#25110;&#23558;&#22270;&#=
23618;&#28155;&#21152;&#21040;&#31354;&#30333;&#30340;&#22320;&#22270;&#2=
5991;&#20214;&#12290;=20
  <P class=3DBreak></P>
  <LI>=93Tools=94&#33756;&#21333;--&gt;=93Customize=94&#12290;=20
  <P class=3DBreak></P>
  <LI>&#28857;&#20987;=93Commands=94&#26631;&#31614;&#12290;=20
  <P class=3DBreak></P>
  =
<LI>&#28857;&#20987;=93Save=94&#32452;&#21512;&#26694;&#26049;&#30340;&#1=
9979;&#31661;&#22836;&#65292;&#24182;&#36873;&#25321;&#26032;&#21629;&#20=
196;&#23558;&#35201;&#20445;&#23384;&#30340;&#22320;&#22270;&#12290;=20
  <P class=3DBreak></P>
  =
<LI>&#28378;&#21160;=93&#31867;&#21035;=94&#21015;&#34920;&#26694;&#65292=
;&#28857;&#20987;=93UIControls=94&#12290;=20
  <P class=3DBreak></P>
  <LI>&#28857;&#20987;=93New UIControl=94&#12290;=20
  <P class=3DBreak></P>
  =
<LI>&#28857;&#20987;UIToolControl&#20316;&#20026;UIControl&#30340;&#31867=
;&#22411;&#12290;=20
  <P class=3DBreak></P>
  <LI>&#28857;&#20987;=93Create=94&#12290;=20
  <P class=3DBreak></P>
  =
<LI>&#23558;=93Commands=94&#21015;&#34920;&#26694;&#20013;&#26032;&#24314=
;&#30340;=93Project.UIToolControl1=94&#25302;&#21160;&#21040;&#20219;&#24=
847;&#24037;&#20855;&#26639;&#19978;&#12290;=20
  <P class=3DBreak></P>
  <LI>&#28857;&#20987;=93Create=94&#12290;=20
  <P class=3DBreak></P>
  =
<LI>&#21491;&#20987;&#21018;&#21046;&#20316;&#22909;&#30340;&#25353;&#380=
62;&#65292;&#28857;&#20987;=93View Source=94&#12290;=20
  <P =
class=3DBreak></P>&#36825;&#26679;&#20415;&#25171;&#24320;&#20102;Visual =
Basic Editor&#12290;=20
  <P class=3DBreak></P>
  =
<LI>&#22312;&#20195;&#30721;&#31383;&#21475;&#20013;&#65292;&#28857;&#209=
87;&#31243;&#24207;&#26694;&#26049;&#30340;&#19979;&#19977;&#35282;&#6528=
8;&#22312;&#31383;&#20307;&#30340;&#21491;&#36793;&#65289;&#65292;&#36873=
;&#25321;=93Click=94&#12290;=20
  <P =
class=3DBreak></P>&#36825;&#26679;&#20415;&#20026;&#20320;&#30340;&#36807=
;&#31243;&#25552;&#20379;&#20102;&#22836;&#23614;&#30340;&#20195;&#30721;=
&#12290;=20
  <P class=3DBreak></P>
  =
<LI>&#22797;&#21046;&#20197;&#19979;&#20195;&#30721;&#24182;&#31896;&#361=
48;&#22312;Click&#20107;&#20214;&#36807;&#31243;&#20013;&#12290;=20
  <P class=3DBreak></P>
  <P></P><PRE class=3Dcode><CODE>Dim pMxDoc As IMxDocument
Set pMxDoc =3D ThisDocument

Dim pActiveView As IActiveView
Set pActiveView =3D pMxDoc.FocusMap
Dim pPoint As IPoint
Set pPoint =3D =
pActiveView.ScreenDisplay.DisplayTransformation.ToMapPoint(x, y)

Dim pBlockSize As IPnt
Set pBlockSize =3D New DblPnt
pBlockSize.SetCoords 1#, 1#

Dim pLayer As IRasterLayer
Dim pPixelBlock As IPixelBlock 'number of bands
Dim vValue As Variant
Dim i As Long, j As Long
Dim sPixelVals As String
sPixelVals =3D "No Raster"
Dim pRasterProps As IRasterProps
Dim dXSize As Double, dYSize As Double
Dim pPixel As IPnt
Set pPixel =3D New DblPnt

For i =3D 0 To pMxDoc.FocusMap.LayerCount - 1
  If (TypeOf pMxDoc.FocusMap.Layer(i) Is IRasterLayer) Then
    Set pLayer =3D pMxDoc.FocusMap.Layer(i) 'if a raster layer then set =
it
    Set pPixelBlock =3D pLayer.Raster.CreatePixelBlock(pBlockSize)

    Set pRasterProps =3D pLayer.Raster
    dXSize =3D pRasterProps.Extent.XMax - pRasterProps.Extent.XMin
    dYSize =3D pRasterProps.Extent.YMax - pRasterProps.Extent.YMin
    dXSize =3D dXSize / pRasterProps.Width
    dYSize =3D dYSize / pRasterProps.Height

    pPixel.x =3D (pPoint.x - pRasterProps.Extent.XMin) / dXSize
    pPixel.y =3D (pRasterProps.Extent.YMax - pPoint.y) / dYSize

    pLayer.Raster.Read pPixel, pPixelBlock
    For j =3D 0 To pPixelBlock.Planes - 1
      If (sPixelVals =3D "No Raster") Then
        sPixelVals =3D "("
      Else
        sPixelVals =3D sPixelVals &amp; ", "
      End If
      vValue =3D pPixelBlock.GetVal(j, 0, 0)
      sPixelVals =3D sPixelVals &amp; CStr(vValue)
    Next j
    If (sPixelVals &lt;&gt; "No Raster") Then sPixelVals =3D sPixelVals =
&amp; ")"
    ThisDocument.Parent.StatusBar.Message(0) =3D "Raster value =3D " =
&amp; sPixelVals
    Exit For
  End If
Next i</CODE></PRE><BR>
  <P class=3DBreak></P>
  <P></P>
  <P></P>
  <LI>&#20851;&#38381;VB&#32534;&#36753;&#22120;&#12290;=20
  <P class=3DBreak></P>
  =
<LI>&#28857;&#20987;&#22312;ArcMap&#20013;&#26032;&#24314;&#30340;&#25511=
;&#21046;&#25353;&#38062;&#65292;&#24182;&#22312;&#26629;&#26684;&#22270;=
&#23618;&#19978;&#31227;&#21160;&#40736;&#26631;&#12290; </LI></OL>
<P class=3DBreak></P>
<P></P>
<TABLE cellPadding=3D5 width=3D"85%" border=3D0>
  <TBODY>
  <TR>
    <TD>
      <H3>&#25552;&#31034;</H3>
      <UL>
        =
<LI>&#35831;&#30830;&#23450;VB&#20013;&#30340;&#20195;&#30721;&#26159;&#2=
0197;&#20197;&#19978;&#27493;&#39588;&#20013;&#30340;&#26684;&#24335;&#20=
986;&#29616;&#12290;&#20363;&#22914;&#65292;&#20320;&#21487;&#33021;&#386=

⌨️ 快捷键说明

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