wsccmm 发表于 2010-8-24 08:22:00

请教各位调用子函数,出现类型不匹配错误。

<p>下面的代码就是要调用子函数画一个长方形,总是出现类型不匹配,有知道为什么吗?</p>
<p>&nbsp; </p>
<p>Sub court()<br/><br/></p>
<p>Dim linep1(0 To 2) As Double '线条端点1<br/>Dim linep2(0 To 2) As Double '线条端点2</p>
<p>xjq = 11000 '小禁区尺寸<br/>djq = 33000 '大禁区尺寸</p>
<p>&nbsp;</p>
<p><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #333333; FONT-FAMILY: 'Tahoma','sans-serif'; mso-fareast-language: ZH-CN; mso-fareast-font-family: SimSun; mso-ansi-language: EN-US; mso-bidi-language: AR-SA">linep1(0) = 0)是-Y<br/>linep1(1) = 0<br/>linep2(0) =&nbsp;xjq <br/>linep2(1) = djq</span></p>
<p><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #333333; FONT-FAMILY: 'Tahoma','sans-serif'; mso-fareast-language: ZH-CN; mso-fareast-font-family: SimSun; mso-ansi-language: EN-US; mso-bidi-language: AR-SA">call drawbox(linep1, linep2) '调用画矩形子程序C</p>
<p><br style="mso-special-character: line-break"/></span>end sub</p>
<p>&nbsp;</p>
<p>Private Sub drawbox(p1, p2)<br/>Dim boxp(0 To 14) As Doublewww.askcad.com J0q8c$z1I7@"M9~"d<br/><br/>boxp(0) = p1(0)3s4U6~ P.J*z W<br/>boxp(1) = p1(1)(askcad.com),为<br/><br/>boxp(3) = p1(0)<br/>boxp(4) = p2(1)<br/>设计论坛$T;F6b6r8r4g },f2n<br/>boxp(6) = p2(0)<br/>boxp(7) = p2(1)www.askcad.com<br/><br/>boxp(9) = p2(0)</p>
<p>boxp(10) = p1(1)<br/><br/>boxp(12) = p1(0)<br/>boxp(13) = p1(1)9F6</p>
<p>Y*y(~'k'o2a9g:<br/><span lang="EN-US" style="FONT-SIZE: 10pt; COLOR: #333333; FONT-FAMILY: 'Tahoma','sans-serif'; mso-fareast-language: ZH-CN; mso-fareast-font-family: SimSun; mso-ansi-language: EN-US; mso-bidi-language: AR-SA">Call ThisDrawing.ModelSpace.AddPolyline(boxp)</span></p>
<p>end sub</p>

pmq 发表于 2010-8-24 21:44:00

绘长方形没问题啊

wsccmm 发表于 2010-8-25 08:29:00

<p>多谢二楼的回复,你用的是哪个版本?我用的2010,绘制不出来呢,也没有查出来是哪里错误呢。</p>
<p>&nbsp;</p>
<p>另外,顺便说一下,这里回贴的人怎么这么少?是问题太简单了,不愿意回答呢?还是说大家都不懂VBA呢?</p>
<p>&nbsp;</p>
<p>各位达人是不应该多帮助下新人啊!</p>

chmenf087 发表于 2010-8-25 10:56:00

<p><font face="Verdana">Private Sub CommandButton2_Click()</font></p>
<p><font face="Verdana">Dim linep1(0 To 2) As Double '线条端点1<br/>Dim linep2(0 To 2) As Double '线条端点2<br/>Dim xjq As Double, djq As Double</font></p><font face="Verdana">
<p><br/>xjq = 11000 '小禁区尺寸<br/>djq = 33000 '大禁区尺寸</p>
<p>&nbsp;</p>
<p>linep1(0) = 0<br/>linep1(1) = 0<br/>linep2(0) = xjq<br/>linep2(1) = djq</p>
<p>Call drawbox(linep1, linep2)</p>
<p>End Sub</p>
<p>&nbsp;</p>
<p>Private Sub drawbox(p1, p2)<br/>Dim boxp(0 To 14) As Double<br/>Dim i As Integer</p>
<p>boxp(0) = p1(0)<br/>boxp(1) = p1(1)</p>
<p>boxp(3) = p1(0)<br/>boxp(4) = p2(1)</p>
<p>boxp(6) = p2(0)<br/>boxp(7) = p2(1)</p>
<p>boxp(9) = p2(0)<br/>boxp(10) = p1(1)</p>
<p>boxp(12) = p1(0)<br/>boxp(13) = p1(1)<br/>For i = 2 To 12 Step 3<br/>&nbsp;boxp(i) = 0<br/>Next i<br/>Call ThisDrawing.ModelSpace.AddPolyline(boxp)</p>
<p>End Sub</font></p>
<p>&nbsp;</p>
<p>试试</p>
页: [1]
查看完整版本: 请教各位调用子函数,出现类型不匹配错误。