tingtingl227 发表于 2009-9-22 15:29:00

各位高手,帮我看看这个编程哪里有错误,该怎么改,谢谢了。急救!!

<p>这是在cad中运用宏,VBA里面编辑的,但是运行老说错误,我想画一个坐标格,然后在最上面标上密度值,请高手帮我改改谢谢</p><p>Public Sub kxxqx()<br/>Dim L(1 To 2) As AcadLine<br/>Dim pnt1(0 To 2) As Double, pnt2(0 To 2) As Double, pnt3(0 To 2) As Double, pnt4(0 To 2) As Double<br/>pnt1(0) = 0: pnt1(1) = 0: pnt1(2) = 0<br/>pnt2(0) = 100: pnt2(1) = 0: pnt2(2) = 0<br/>pnt3(0) = 0: pnt3(1) = 0: pnt3(2) = 0<br/>pnt4(0) = 0: pnt4(1) = -100: pnt4(2) = 0<br/>Set L1 = ThisDrawing.ModelSpace.AddLine(pnt1, pnt2)<br/>Set L2 = ThisDrawing.ModelSpace.AddLine(pnt3, pnt4)<br/>Dim L3 As Variant: Dim L4 As Variant: Dim L5 As Variant: Dim L6 As Variant: Dim L7 As Variant<br/>Dim L8 As Variant: Dim L9 As Variant: Dim L10 As Variant: Dim L11 As Variant:<br/>Dim L12 As Variant<br/>L3 = L1.Offset(-20)<br/>L4 = L1.Offset(-40)<br/>L5 = L1.Offset(-60)<br/>L6 = L1.Offset(-80)<br/>L7 = L1.Offset(-100)<br/>L8 = L2.Offset(20)<br/>L9 = L2.Offset(40)<br/>L10 = L2.Offset(60)<br/>L11 = L2.Offset(80)<br/>L12 = L2.Offset(100)<br/>ZoomExtents<br/>End Sub<br/>Public Sub 标注密度坐标值()<br/>Dim den(1 To 7) As AcadText<br/>Dim txt(1 To 6) As String<br/>Dim inspnt1(0 To 2) As Double: Dim inspnt2(0 To 2) As Double: Dim inspnt3(0 To 2) As Double<br/>Dim inspnt4(0 To 2) As Double: Dim inspnt5(0 To 2) As Double: Dim inspnt6(0 To 2) As Double: Dim inspnt7(0 To 2) As Double<br/>Dim height As Double<br/>txt1 = " 2.2": txt2 = " 2.0": txt3 = " 1.8": txt4 = " 1.6": txt5 = " 1.4": txt6 = " 1.2": txt7 = " 密度"<br/>inspnt1(0) = -2: inspnt1(1) = 1: inspnt1(2) = 0<br/>inspnt2(0) = 18: inspnt2(1) = 1: inspnt2(2) = 0<br/>inspnt3(0) = 38: inspnt3(1) = 1: inspnt3(2) = 0<br/>inspnt4(0) = 58: inspnt4(1) = 1: inspnt4(2) = 0<br/>inspnt5(0) = 78: inspnt5(1) = 1: inspnt5(2) = 0<br/>inspnt6(0) = 98: inspnt6(1) = 1: inspnt6(2) = 0<br/>inspnt7(0) = 48: inspnt7(1) = 5: inspnt7(2) = 0<br/>Set den1 = ThisDrawing.ModelSpace.AddText(txt1, inspnt1, height)<br/>Set den2 = ThisDrawing.ModelSpace.AddText(txt2, inspnt2, height)<br/>Set den3 = ThisDrawing.ModelSpace.AddText(txt3, inspnt3, height)<br/>Set den4 = ThisDrawing.ModelSpace.AddText(txt4, inspnt4, height)<br/>Set den5 = ThisDrawing.ModelSpace.AddText(txt5, inspnt5, height)<br/>Set den6 = ThisDrawing.ModelSpace.AddText(txt6, inspnt6, height)<br/>Set den7 = ThisDrawing.ModelSpace.AddText(txt7, inspnt7, height)<br/>ZoomExtents<br/>End Sub</p>

雪山飞狐_lzh 发表于 2009-9-23 07:55:00

<p>高度没有赋值</p><p>Public Sub 标注密度坐标值()<br/>Dim den(1 To 7) As AcadText<br/>Dim txt(1 To 6) As String<br/>Dim inspnt1(0 To 2) As Double: Dim inspnt2(0 To 2) As Double: Dim inspnt3(0 To 2) As Double<br/>Dim inspnt4(0 To 2) As Double: Dim inspnt5(0 To 2) As Double: Dim inspnt6(0 To 2) As Double: Dim inspnt7(0 To 2) As Double<br/>Dim height As Double<br/>txt1 = " 2.2": txt2 = " 2.0": txt3 = " 1.8": txt4 = " 1.6": txt5 = " 1.4": txt6 = " 1.2": txt7 = " 密度"<br/>inspnt1(0) = -2: inspnt1(1) = 1: inspnt1(2) = 0<br/>inspnt2(0) = 18: inspnt2(1) = 1: inspnt2(2) = 0<br/>inspnt3(0) = 38: inspnt3(1) = 1: inspnt3(2) = 0<br/>inspnt4(0) = 58: inspnt4(1) = 1: inspnt4(2) = 0<br/>inspnt5(0) = 78: inspnt5(1) = 1: inspnt5(2) = 0<br/>inspnt6(0) = 98: inspnt6(1) = 1: inspnt6(2) = 0<br/>inspnt7(0) = 48: inspnt7(1) = 5: inspnt7(2) = 0<br/><font color="#ff0000">height = 5<br/></font>Set den1 = ThisDrawing.ModelSpace.AddText(txt1, inspnt1, height)<br/>Set den2 = ThisDrawing.ModelSpace.AddText(txt2, inspnt2, height)<br/>Set den3 = ThisDrawing.ModelSpace.AddText(txt3, inspnt3, height)<br/>Set den4 = ThisDrawing.ModelSpace.AddText(txt4, inspnt4, height)<br/>Set den5 = ThisDrawing.ModelSpace.AddText(txt5, inspnt5, height)<br/>Set den6 = ThisDrawing.ModelSpace.AddText(txt6, inspnt6, height)<br/>Set den7 = ThisDrawing.ModelSpace.AddText(txt7, inspnt7, height)<br/>ZoomExtents<br/>End Sub<br/></p>
页: [1]
查看完整版本: 各位高手,帮我看看这个编程哪里有错误,该怎么改,谢谢了。急救!!