问题很简单,看看示例文件就可自己解决。文本框控件显得有点乱,可再整理一下。 在窗体模块中添加以下代码: Option Explicit Private Sub CommandButton1_Click() Dim X, b, c, Y, e, f, X2, g, h, Y2, i, j As Double b = Val(TextBox2.Text) c = Val(TextBox3.Text) e = Val(TextBox5.Text) f = Val(TextBox6.Text) g = Val(TextBox8.Text) h = Val(TextBox9.Text) i = Val(TextBox11.Text) j = Val(TextBox12.Text) X = b + c Y = e + f X2 = g + h Y2 = i + j TextBox1.Text = X TextBox4.Text = Y TextBox7.Text = X2 TextBox10.Text = Y2 Dim lineObj As AcadLine Dim startPoint(0 To 2) As Double Dim endPoint(0 To 2) As Double ' 定义直线的起点和终点 startPoint(0) = X: startPoint(1) = Y: startPoint(2) = 0# endPoint(0) = X2: endPoint(1) = Y2: endPoint(2) = 0# ' 在模型空间中创建直线 Set lineObj = ThisDrawing.ModelSpace.AddLine(startPoint, endPoint) ZoomAll End Sub |