桃花小妖 发表于 2005-10-28 09:43:00

[VBA]编辑文字的问题

<P>Sub addtext(ByVal X As Variant, ByVal Y As Variant, TextHeight As Double, textString As String)<BR>&nbsp;&nbsp;&nbsp;&nbsp; Dim tsObj1 As AcadTextStyle<BR>&nbsp; Set tsObj1 = ThisDrawing.TextStyles.Add("tsObj1")<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ThisDrawing.ActiveTextStyle = tsObj1<BR>&nbsp;&nbsp;&nbsp;&nbsp; Dim typeface1 As String<BR>&nbsp;&nbsp;&nbsp;&nbsp; Dim bold1 As Boolean<BR>&nbsp;&nbsp;&nbsp;&nbsp; Dim italic1 As Boolean<BR>&nbsp;&nbsp;&nbsp;&nbsp; Dim charset1 As Long<BR>&nbsp;&nbsp;&nbsp;&nbsp; Dim pitchandfamily1 As Long</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp; Dim textObj As AcadText<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; typeface1 = "仿宋_GB2312"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bold1 = False<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; italic1 = False<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; charset1 = DEFAULT_CHARSET<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; pitchandfamily1 = FIXED_PITCH</P>
<P>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tsObj1.SetFont typeface1, bold1, italic1, charset1, pitchandfamily1<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tsObj1.height = 40<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; tsObj1.width = 0.75</P>
<P><BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Dim insPnt(0 To 2)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; insPnt(0) = X: insPnt(1) = Y: insPnt(2) = 0<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; TextHeight = 100<BR>&nbsp;&nbsp;&nbsp;&nbsp; Set textObj = ThisDrawing.ModelSpace.addtext(insPnt, TextHeight, textString)<BR>&nbsp;&nbsp;&nbsp;&nbsp; textObj.StyleName = "tsObj1"<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; textObj.Update<BR>End Sub</P>
<P>运行之后在Set textObj = ThisDrawing.ModelSpace.addtext(insPnt, TextHeight, textString) 的insPnt 提示我类型不匹配,我是初学者,请大家帮忙看看。</P>

雪山飞狐_lzh 发表于 2005-10-28 09:48:00

Dim insPnt(0 To 2) as double

桃花小妖 发表于 2005-10-28 09:50:00

问题不在这,本来是Dim insPnt(0 To 2) as double这样的,运行之后提示还是“类型不匹配”

wmz 发表于 2005-10-28 12:33:00

<DIV>&nbsp;这一句:</DIV>
<DIV>Set textObj = ThisDrawing.ModelSpace.addtext(insPnt, TextHeight, textString)</DIV>
<DIV>改成:<BR>&nbsp;Set textObj = ThisDrawing.ModelSpace.addtext(textString,insPnt, TextHeight)<BR></DIV>

macula 发表于 2005-10-28 16:09:00

<P>把:X、Y的数据类型改为双精度</P>
页: [1]
查看完整版本: [VBA]编辑文字的问题