weixin7944 发表于 2006-8-7 12:34:00

程序运行后产生的问题

<P>最近变了一个程序,如下:</P>
<P>Private Sub CommandButton2_Click()<BR>Dim pt As Variant<BR>Dim textobject As AcadText<BR>Dim pt1 As Variant<BR>Dim pt2 As Variant<BR>Dim pt3 As Variant<BR>Dim pt4 As Variant<BR>Dim pt5 As Variant<BR>Dim pt6 As Variant<BR>Dim pt7 As Variant<BR>frmMain.Hide<BR>pt = ThisDrawing.Utility.GetPoint(, "请输入插入点!")<BR>pt1(0) = pt(0) + 488: pt1(1) = pt(0) - 884<BR>pt2(0) = pt(0) + 5002: pt2(1) = pt(0) - 890<BR>pt3(0) = pt(0) + 9148: pt3(1) = pt(0) - 752<BR>pt4(0) = pt(0) + 9189: pt4(1) = pt(0) - 1250<BR>pt5(0) = pt(0) + 23067: pt5(1) = pt(0) - 884<BR>pt6(0) = pt(0) + 24475: pt6(1) = pt(0) - 984<BR>pt7(0) = pt(0) + 9138: pt7(1) = pt(0) - 965<BR>Set textobject = ThisDrawing.ModelSpace.AddText("sfsf", pt1, 500)<BR>End Sub</P>
<P>程序运行到pt1(0) = pt(0) + 488: pt1(1) = pt(0) - 884<BR>调试错误,提示类型不匹配!请问是什么原因?另,在输入汉字时怎么规定字体?谢谢!</P>

wyj7485 发表于 2006-8-7 14:23:00

<P>Dim pt As Variant<BR>Dim textobject As AcadText<BR>Dim pt1(2) As Double</P>
<P><BR>pt = ThisDrawing.Utility.GetPoint(, "请输入插入点!")<BR>pt1(0) = pt(0) + 488: pt1(1) = pt(0) - 884: pt1(2) = 0</P>
<P>Set textobject = ThisDrawing.ModelSpace.AddText("sfsf", pt1, 500)</P>

weixin7944 发表于 2006-8-8 12:24:00

谢谢!顺便请问一下怎样为输入的汉字设置字体?

雪山飞狐_lzh 发表于 2006-8-9 22:06:00

<P>你搜索一下吧,很多的</P>

weixin7944 发表于 2006-8-10 19:16:00

<P>找到了一个,如下:</P>
<P>set ts = ThisDrawing.ActiveTextStyle<BR>tsna = ts.fontFile<BR>&nbsp;&nbsp;&nbsp; Set ts1 = ThisDrawing.ActiveTextStyle<BR>&nbsp;&nbsp;&nbsp; ts1.fontFile = "HZTXT"<BR>ThisDrawing.ActiveTextStyle = ts1<BR>Set textobject = ThisDrawing.ModelSpace.AddText("汉字",pt5, 500)<BR>ThisDrawing.Regen acActiveViewport<BR>ts.fontFile = tsna<BR>ThisDrawing.ActiveTextStyle = ts</P>
<P>确实程序执行时,我采用MSGBOX看字体,气体确实由原来的ROMANS 便成了HZTXT,然后写入"汉字"两个字,之后又变成了原来的ROMANS。但是当我在查看CAD中"汉字"两个字的字体时,却是ROMANS。不知道为什么,请指教!</P>
页: [1]
查看完整版本: 程序运行后产生的问题