明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1640|回复: 4

[VBA]编辑文字的问题

[复制链接]
发表于 2005-10-28 09:43:00 | 显示全部楼层 |阅读模式

Sub addtext(ByVal X As Variant, ByVal Y As Variant, TextHeight As Double, textString As String)
     Dim tsObj1 As AcadTextStyle
  Set tsObj1 = ThisDrawing.TextStyles.Add("tsObj1")
       ThisDrawing.ActiveTextStyle = tsObj1
     Dim typeface1 As String
     Dim bold1 As Boolean
     Dim italic1 As Boolean
     Dim charset1 As Long
     Dim pitchandfamily1 As Long

     Dim textObj As AcadText
       typeface1 = "仿宋_GB2312"
       bold1 = False
       italic1 = False
       charset1 = DEFAULT_CHARSET
       pitchandfamily1 = FIXED_PITCH

      tsObj1.SetFont typeface1, bold1, italic1, charset1, pitchandfamily1
      tsObj1.height = 40
      tsObj1.width = 0.75


        Dim insPnt(0 To 2)
       insPnt(0) = X: insPnt(1) = Y: insPnt(2) = 0
       TextHeight = 100
     Set textObj = ThisDrawing.ModelSpace.addtext(insPnt, TextHeight, textString)
     textObj.StyleName = "tsObj1"
        textObj.Update
End Sub

运行之后在Set textObj = ThisDrawing.ModelSpace.addtext(insPnt, TextHeight, textString) 的insPnt 提示我类型不匹配,我是初学者,请大家帮忙看看。

发表于 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这样的,运行之后提示还是“类型不匹配”
发表于 2005-10-28 12:33:00 | 显示全部楼层
 这一句:
Set textObj = ThisDrawing.ModelSpace.addtext(insPnt, TextHeight, textString)
改成:
 Set textObj = ThisDrawing.ModelSpace.addtext(textString,insPnt, TextHeight)
发表于 2005-10-28 16:09:00 | 显示全部楼层

把:X、Y的数据类型改为双精度

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-27 08:46 , Processed in 0.159879 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表