gzxl 发表于 2010-6-25 22:02:00

[求助]VB提取文字

<p>&nbsp;</p>
<p>此段VB代码为何只能提取数字型的文字,却提取不了中文的文本?</p>
<p>请高手帮忙!</p>
<p>&nbsp;</p>
<p><font face="Verdana">On Error Resume Next<br/>Set acadApp = GetObject(, "AutoCAD.Application.16")<br/>If ERR Then<br/>ERR.Clear<br/>Set acadApp = CreateObject("AutoCAD.Application.16")<br/>If ERR Then End<br/>End If<br/>acadApp.Visible = True<br/>Dim acadDoc As AcadDocument<br/>acadApp.WindowState = acMax<br/>Set acadDoc = acadApp.ActiveDocument</font></p><font face="Verdana">
<p><br/>Set excel = GetObject(, "Excel.Application")<br/>Set xlSheet = excel.ActiveWorkbook.Sheets("sheet1")</p>
<p>Dim a As Double<br/>Dim b As Double<br/>a = TextBox1.Text<br/>b = TextBox2.Text</p>
<p><font color="#ff0000">acadDoc.Utility.GetEntity returnObj, basepnt, "选择文字:"<br/>If returnObj.ObjectName = "AcDbText" Or returnObj.ObjectName = "AcDbMText" Then<br/>ptcen = returnObj.TextString<br/>returnObj.Update<br/>xlSheet.Cells(a, b) = Round(ptcen)</font><br/>End If</font></p>

wwswwswws 发表于 2010-8-23 15:02:00

你用Round函数,当然单元格内的数是数字了,这个函数是对数字取四舍五入的函数。你在这句xlSheet.Cells(a, b) = Round(ptcen)之前加上一句:debug.print ptcen试一下看,肯定是可以得到中文文字的。
页: [1]
查看完整版本: [求助]VB提取文字