ry888 发表于 2008-2-19 09:54:00

如何写“通过点选获得封闭区域面积”的代码

想用VB6如何实现以下的功能:
利用鼠标点选功能先获得对一个封闭区域的选择,然后获得该区域的面积。
谢谢

azjmjsj 发表于 2008-2-19 20:25:00

给你一段VBA代码,自己改到VB中
Public Sub FB_Area()
Dim cecho As Variant
cecho = ThisDrawing.GetVariable("cmdecho")
ThisDrawing.SetVariable "cmdecho", 0
Dim pt As Variant
pt = ThisDrawing.Utility.GetPoint(, "点击封闭区域内部...")
Dim spt As String
spt = pt(0) & "," & pt(1)
ThisDrawing.SendCommand Chr(3) & Chr(3) & "-boundary " & spt & " " & " "
ThisDrawing.SendCommand "draworder lastf "
ThisDrawing.SendCommand "_.area o last "
ThisDrawing.SendCommand Chr(3) & Chr(3)
MsgBox vbCrLf & "封闭区域面积为:" & CStr(ThisDrawing.GetVariable("AREA"))
ThisDrawing.SetVariable "CMDECHO", cecho
End Sub

ry888 发表于 2008-2-20 08:32:00

谢谢

sunny2008 发表于 2008-2-25 18:49:00

谢谢 我先试试
页: [1]
查看完整版本: 如何写“通过点选获得封闭区域面积”的代码