阅读:1196回复:0
[求助]如何用VBA向Polyline数据属性表中一个字段赋值
<P>Polyline数据属性表中有个Angle的字段,现在已经计算出Angle的值,比如说变量dAngle是在VBA中代表字段Angle的值,下面是Gisempire一位朋友给的代码,小弟初学,不知道字段Angle的接口是什么,请问如何把dAngle的值赋给字段Angle?谢谢了!</P>
<P><FONT face="Times New Roman">Sub Gisempire_lineway()<p></p></FONT></P> <P ><FONT face="Times New Roman"> Dim pDoc As IMxDocument<p></p></FONT></P> <P ><FONT face="Times New Roman"> Dim pMap As IMap<p></p></FONT></P> <P ><FONT face="Times New Roman"> Dim pEnumFeat As IEnumFeature<p></p></FONT></P> <P ><FONT face="Times New Roman"> Dim pFeat As IFeature<p></p></FONT></P> <P ><FONT face="Times New Roman"> <p></p></FONT></P> <P ><FONT face="Times New Roman"> Set pDoc = ThisDocument<p></p></FONT></P> <P ><FONT face="Times New Roman"> Set pMap = pDoc.FocusMap<p></p></FONT></P> <P ><FONT face="Times New Roman"> Set pEnumFeat = pMap.FeatureSelection<p></p></FONT></P> <P ><FONT face="Times New Roman"> Set pFeat = pEnumFeat.Next<p></p></FONT></P> <P ><FONT face="Times New Roman"> Do While (Not pFeat Is Nothing)<p></p></FONT></P> <P ><FONT face="Times New Roman">If pFeat.Shape.GeometryType = 3 Then<p></p></FONT></P> <P ><FONT face="Times New Roman"> Dim pline As IPolyline<p></p></FONT></P> <P ><FONT face="Times New Roman"> Set pline = pFeat.Shape<p></p></FONT></P> <P ><FONT face="Times New Roman"> Dim iline As iline<p></p></FONT></P> <P ><FONT face="Times New Roman"> Set iline = New Line<p></p></FONT></P> <P ><FONT face="Times New Roman"> iline.FromPoint = pline.FromPoint<p></p></FONT></P> <P ><FONT face="Times New Roman"> iline.ToPoint = pline.ToPoint<p></p></FONT></P> <P ><FONT face="Times New Roman"> Dim dAngle As Double<p></p></FONT></P> <P ><FONT face="Times New Roman"> dAngle = (180 * iline.Angle) / (4 * Atn(1))<p></p></FONT></P> <P ><FONT face="Times New Roman"> If dAngle < 0 Then<p></p></FONT></P> <P ><FONT face="Times New Roman"> dAngle = dAngle + 360<p></p></FONT></P> <P ><FONT face="Times New Roman"> End If<p></p></FONT></P> <P ><FONT face="Times New Roman"> MsgBox dAngle<p></p></FONT></P> <P ><FONT face="Times New Roman"> End If<p></p></FONT></P> <P ><FONT face="Times New Roman"> Set pFeat = pEnumFeat.Next<p></p></FONT></P> <P ><FONT face="Times New Roman"> <st1:place w:st="on">Loop</st1:place><p></p></FONT></P> <P ><FONT face="Times New Roman">End Sub<p></p></FONT></P> |
|