- 积分
- 178
- 明经币
- 个
- 注册时间
- 2003-3-6
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
下面是我对text文本编辑用的源程序,但是如果简单的该成对多行文本进行操作的话,程序不能起作用,我要修改编号的多行文本是包括两行文字的,不知道多行文本中有回车的话该如果操作?
Dim textObj As AcadText
Dim aaa As String
Dim bbb As Double
Dim ss As AcadSelectionSet
Dim Enf As AcadEntity
Dim Ent As AcadText
Dim qq As String
Dim cd As Double
Dim xhcd As Double
Dim zj As Double
Dim changdu As Double
Dim zero As String
Dim errornumber
Sub 改编号程序()
MsgBox "该程序用于编号+1"
On Error Resume Next
qq = ThisDrawing.Utility.GetString(20, vbCrLf & "请输入要更改的ISO代号:" & vbCrLf)
On Error Resume Next
cd = ThisDrawing.Utility.GetString(1, vbCrLf & "请输入刚才输入ISO代号的长度:" & vbCrLf)
On Error Resume Next
xhcd = ThisDrawing.Utility.GetString(1, vbCrLf & "请输入识别用后面的编号长度1~4)" & vbCrLf)
On Error Resume Next
zj = CDbl(ThisDrawing.Utility.GetString(4, vbCrLf & "请输入条件Number(编号>Number)" & vbCrLf))
Set ss = GetSelSet
For Each Enf In ss
If Enf.ObjectName = "AcDbText" Then
changdu = Len(CStr(Enf.textString))
changdu = changdu - CDbl(xhcd)
aaa = Right(CStr(Enf.textString), CDbl(xhcd))
bbb = CDbl(aaa)
If bbb > CDbl(zj) And Left(CStr(Enf.textString), CDbl(cd)) = CStr(qq) Then
bbb = CDbl(aaa) + 1
aaa = CDbl(bbb)
Select Case xhcd
Case Is = 1
zero = ""
Enf.textString = Left(CStr(Enf.textString), CDbl(changdu)) & CStr(aaa)
Case Is = 2
zero = "0"
Select Case bbb
Case Is < 10
Enf.textString = Left(CStr(Enf.textString), CDbl(changdu)) & "0" & CStr(aaa)
Case Is >= 10
Enf.textString = Left(CStr(Enf.textString), CDbl(changdu)) & CStr(aaa)
End Select
Case Is = 3
zero = "00"
Select Case bbb
Case Is < 10
Enf.textString = Left(CStr(Enf.textString), CDbl(changdu)) & CStr(zero) & CStr(aaa)
Case Is >= 100
Enf.textString = Left(CStr(Enf.textString), CDbl(changdu)) & CStr(aaa)
Case Is >= 10
Enf.textString = Left(CStr(Enf.textString), CDbl(changdu)) & Left(CStr(zero), 1) & CStr(aaa)
End Select
Case Is = 4
zero = "000"
Select Case bbb
Case Is < 10
Enf.textString = Left(CStr(Enf.textString), CDbl(changdu)) & CStr(zero) & CStr(aaa)
Case Is >= 1000
Enf.textString = Left(CStr(Enf.textString), CDbl(changdu)) & CStr(aaa)
Case Is >= 100
Enf.textString = Left(CStr(Enf.textString), CDbl(changdu)) & Left(CStr(zero), 1) & CStr(aaa)
Case Is >= 10
Enf.textString = Left(CStr(Enf.textString), CDbl(changdu)) & Left(CStr(zero), 2) & CStr(aaa)
End Select
End Select
End If
End If
Next
line1:
End Sub
Function GetSelSet() As AcadSelectionSet
Dim ss As AcadSelectionSet
Set ss = ThisDrawing.PickfirstSelectionSet
If ss.Count = 0 Then
Dim ssName As String
ssName = "strSSet"
On Error Resume Next
Set ss = ThisDrawing.SelectionSets(ssName)
If Err Then Set ss = ThisDrawing.SelectionSets.Add(ssName)
ss.Clear
ss.SelectOnScreen
End If
Set GetSelSet = ss
End Function |
|