[VBA]编辑文字的问题
<P>Sub addtext(ByVal X As Variant, ByVal Y As Variant, TextHeight As Double, textString As String)<BR> Dim tsObj1 As AcadTextStyle<BR> Set tsObj1 = ThisDrawing.TextStyles.Add("tsObj1")<BR> ThisDrawing.ActiveTextStyle = tsObj1<BR> Dim typeface1 As String<BR> Dim bold1 As Boolean<BR> Dim italic1 As Boolean<BR> Dim charset1 As Long<BR> Dim pitchandfamily1 As Long</P><P> Dim textObj As AcadText<BR> typeface1 = "仿宋_GB2312"<BR> bold1 = False<BR> italic1 = False<BR> charset1 = DEFAULT_CHARSET<BR> pitchandfamily1 = FIXED_PITCH</P>
<P> tsObj1.SetFont typeface1, bold1, italic1, charset1, pitchandfamily1<BR> tsObj1.height = 40<BR> tsObj1.width = 0.75</P>
<P><BR> Dim insPnt(0 To 2)<BR> insPnt(0) = X: insPnt(1) = Y: insPnt(2) = 0<BR> TextHeight = 100<BR> Set textObj = ThisDrawing.ModelSpace.addtext(insPnt, TextHeight, textString)<BR> textObj.StyleName = "tsObj1"<BR> textObj.Update<BR>End Sub</P>
<P>运行之后在Set textObj = ThisDrawing.ModelSpace.addtext(insPnt, TextHeight, textString) 的insPnt 提示我类型不匹配,我是初学者,请大家帮忙看看。</P> Dim insPnt(0 To 2) as double 问题不在这,本来是Dim insPnt(0 To 2) as double这样的,运行之后提示还是“类型不匹配” <DIV> 这一句:</DIV>
<DIV>Set textObj = ThisDrawing.ModelSpace.addtext(insPnt, TextHeight, textString)</DIV>
<DIV>改成:<BR> Set textObj = ThisDrawing.ModelSpace.addtext(textString,insPnt, TextHeight)<BR></DIV> <P>把:X、Y的数据类型改为双精度</P>
页:
[1]