试试这个
Public Sub LinkTextWithAttrib()Dim oEnt As AcadEntityDim oAttr As AcadAttributeReferenceDim oText As AcadTextDim idAttr As LongDim strVal As StringDim attFieldStr As StringDim varPt,tmax,contxOn Error GoTo Err\u Control'prefix=InputBox(“输入前缀:”,“Link Text with Attribute”,“LOOP21-”)''If prefix=“”那么'MsgBox“您没有输入值。”'退出此绘图的Sub'End。公用事业GetSubEntity oEnt,varPt,tmax,contx,_“选择属性:”如果oEnt为Nothing ThenMsgBox“Nothing Selected”退出子端如果oEnt的类型不是AcadAttributeReference ThenMsgBox“Selected Is Not a AttributeReference”退出子端如果设置oAttr=oEntstrVal=oAttr。TextStringIf Not strVal Like“LOOP21-*”ThenMsgBox“此属性不包含前缀“АВВ”“”Exit SubEnd IfDim pospospos=InStr(strVal,“-”)ThisDrawing。公用事业GetSubEntity oEnt,varPt,tmax,contx,“选择一个文本:”如果oEnt为Nothing ThenMsgBox“Nothing Selected”如果oEnt的类型不是AcadText,则退出子端ThenMsgBox“Selected Is Not a Text”退出子端IfSet oText=oEntDim txtFieldStr As String“如何在字段中使用diesel:txtFieldStr=“%”