我这样用VBA在CAD中画一条直线为何总报错
Subcc()Dimp1(2),p2(2)AsDoublep1(0)=0p1(1)=0p1(2)=0p2(0)=100p2(1)=100p2(2)=0CallThisDr...
Sub cc()
Dim p1(2), p2(2) As Double
p1(0) = 0
p1(1) = 0
p1(2) = 0
p2(0) = 100
p2(1) = 100
p2(2) = 0
Call ThisDrawing.ModelSpace.AddLine(p1,p2)
End Sub
总是说"无效的过程调用或参数",运行时错误'5'
用utility.getpoint画出来的点没有问题 展开
Dim p1(2), p2(2) As Double
p1(0) = 0
p1(1) = 0
p1(2) = 0
p2(0) = 100
p2(1) = 100
p2(2) = 0
Call ThisDrawing.ModelSpace.AddLine(p1,p2)
End Sub
总是说"无效的过程调用或参数",运行时错误'5'
用utility.getpoint画出来的点没有问题 展开
1个回答
展开全部
Dim p1(2) As Double, p2(2) As Double 试试看,我不确定
追问
太牛了,问题是为啥这样呢???
我试了,OK
追答
因为vb/vba里面定义变量,as要分别说明.比如 dim a as integer,b as double,c as string,如果只是dim a,b as double,则a是变体型(Variant,vba默认类型),只有b才是double型。这点跟c等其他语言不同,c里面可以int a,b (a和b都是int型)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询