属性杂耍。。
您好,我有一个标题栏,有7个可能的修订数据属性-REV1到REV7(以及修订者的首字母的7个可能属性-REVBY1到REVBY7),当布局在第8次修订7次时,当然没有更多的空间来添加最新的修订细节,所以我想通过编程删除第一个实例REV1和';分流器#039;所有其他的都在列表中,为最后一个版本7中的新细节留出了空间…
…因此,当它正常工作时,版本1中的内容被删除并替换为版本2中的内容,然后版本3中的内容现在变成了版本2,等等等等,布拉·亚达……实现这一点的最佳方法是什么?我是否需要循环遍历块的属性,将这些属性的文本字符串传递到字符串数组,然后再次循环遍历并以我需要的方式用数组中的内容替换文本字符串,然后将新的细节放入REV7 textstring中。
这个程序是我上载的程序的一部分,用于处理';布局、列表框和其他L字;我最近发布的线程(见下面的附加程序和测试图)已经完成,但想添加这一点,以真正完善它。
我知道我的代码很不整洁,我的方式';我做的事情可能有点笨拙,但我';我对这件事比较陌生,我所知道的一切都是自学成才的,都是从你们扔给我的残羹剩饭中学来的,所以我向你们道歉
**** Hidden Message ***** 我不会';我甚至不能把它放到一个数组中。我会把所有的东西都放在一根绳子里,然后在需要的时候把绳子分开
是的,你的方法就是我的方法 好的,谢谢。那么如何分割阵列呢?本人';我看过/听说过Split(),但你能简单地给我解释一下吗。这就像是通过检查逗号来分隔一种逗号分隔的列表吗''
问题是,我不知道你是否';我检查了程序,但当我点击这个#039;完整表格#039;程序的一部分,i';我已经在一个循环中循环属性了,我可以在第一个主循环中再次(两次)循环属性吗,还是程序会抛出一个spaz? 是的,你可以任意多次嵌套循环。我会创建一个用唯一字符分隔的字符串,或者是在实践中永远不会使用的字符串
[代码这将把所有属性值连接在一起。然后,当需要返回值时dim MyVals as variant
MyVals = split(MyString,"#:#",,vbTextCompare) 这将为您提供一个基于零的值数组,编辑以更正代码 示例Dim MyString As String
Dim X As Integer
For X = 0 To 10
MyString = MyString & X & "#:#"
Next X
Dim MyValues As Variant
MyValues = Split(MyString, "#:#", , vbTextCompare)  
MyString then=";0#:#1 35;:#:2 35;:35;#3 35#::4 35;5 35;6 35难:35;; 7 35安:35安:9 35纳:35纳什:10 35纳:35纳什
分割后,它变为MyValues(0) : "0"
MyValues(1) : "1"
MyValues(2) : "2"
MyValues(3) : "3"
MyValues(4) : "4"
MyValues(5) : "5"
MyValues(6) : "6"
MyValues(7) : "7"
MyValues(8) : "8"
MyValues(9) : "9"
MyValues(10) : "10"
MyValues(11) : "" 您好,
哈文#039;我还没有试过分裂的方法,但谢谢你提醒我,这看起来是一个很好的方法。本人';我现在坚持使用字符串数组,但有一次我';我再仔细研究一下分裂的事情,我';我将使用它。无论哪种方式,我在循环块的属性时遇到了问题,但以相反的方式循环。当然,您必须能够以相反的顺序循环属性(即:从Ubound到Lbound)。本人';我正在尝试,但在Select Case Attrib分流(CountV)上出错。标记字符串行(见下面的代码),带有一个
&039;下标超出范围#039
错误Public Sub SHUNT_REVS()
' *******************************************************
'Loop through titleblock once to get attribute values..
Dim EntSHUNT As AcadObject
Dim AttribSHUNT As Variant
Dim CountV as Integer
Dim REV7shunt(0 To 6) As String
Dim REVBY7shunt(0 To 6) As String
For Each EntSHUNT In ThisDrawing.PaperSpace
If EntSHUNT.EntityName = "AcDbBlockReference" Then
AttribSHUNT = EntSHUNT.GetAttributes
For CountV = UBound(AttribSHUNT) To LBound(AttribSHUNT)
Select Case AttribSHUNT(CountV).TagString
Case "REVBY7"
REVBY7shunt(6) = AttribSHUNT(CountV).TextString 'Add this rev detail to the string array for if titleblock is full..
AttribSHUNT(CountV).TextString = revBY ' Add newest detail to the 7th rev detail..
Case "REVBY6"
REVBY7shunt(5) = AttribSHUNT(CountV).TextString 'Add this rev detail to the string array for if titleblock is full..
AttribSHUNT(CountV).TextString = REVBY7shunt(6)
Case "REVBY5"
REVBY7shunt(4) = attribZ(CountV).TextString 'Add this rev detail to the string array for if titleblock is full..
attribZ(CountV).TextString = REVBY7shunt(5)
Case "REVBY4"
REVBY7shunt(3) = AttribSHUNT(CountV).TextString 'Add this rev detail to the string array for if titleblock is full..
AttribSHUNT(CountV).TextString = REVBY7shunt(4)
Case "REVby3"
REVBY7shunt(2) = AttribSHUNT(CountV).TextString 'Add this rev detail to the string array for if titleblock is full..
AttribSHUNT(CountV).TextString = REVBY7shunt(3)
Case "REVBY2"
REV7shunt(1) = AttribSHUNT(CountV).TextString 'Add this rev detail to the string array for if titleblock is full..
AttribSHUNT(CountV).TextString = REVBY7shunt(2)
Case "REVBY1"
REVBY7shunt(0) = AttribSHUNT(CountV).TextString 'Add this rev detail to the string array for if titleblock is full..
AttribSHUNT(CountV).TextString = REVBY7shunt(1)
Case "REV7"
REV7shunt(6) = AttribSHUNT(CountV).TextString 'Add this rev detail to the string array for if titleblock is full..
AttribSHUNT(CountV).TextString = UCase(revnumber) & " - " & UCase(revdetails) & " - " & Date ' Add newest detail to the 7th rev detail..
Case "REV6"
REV7shunt(5) = AttribSHUNT(CountV).TextString 'Add this rev detail to the string array for if titleblock is full..
AttribSHUNT(CountV).TextString = REV7shunt(6)
Case "REV5"
REV7shunt(4) = AttribSHUNT(CountV).TextString 'Add this rev detail to the string array for if titleblock is full..
AttribSHUNT(CountV).TextString = REV7shunt(5)
Case "REV4"
REV7shunt(3) = AttribSHUNT(CountV).TextString 'Add this rev detail to the string array for if titleblock is full..
AttribSHUNT(CountV).TextString = REV7shunt(4)
Case "REV3"
REV7shunt(2) = AttribSHUNT(CountV).TextString 'Add this rev detail to the string array for if titleblock is full..
AttribSHUNT(CountV).TextString = REV7shunt(3)
Case "REV2"
REV7shunt(1) = AttribSHUNT(CountV).TextString 'Add this rev detail to the string array for if titleblock is full..
AttribSHUNT(CountV).TextString = REV7shunt(2)
Case "REV1"
REV7shunt(0) = AttribSHUNT(CountV).TextString 'Add this rev detail to the string array for if titleblock is full..
AttribSHUNT(CountV).TextString = REV7shunt(1)
End Select
Next CountV
End If 'If entx is block..
Next EntSHUNT
End Sub 有什么想法吗?有什么问题吗
我有039;t深入研究了代码,但尝试一下…
For CountV = UBound(AttribSHUNT) To LBound(AttribSHUNT) Step -1
现在明白了,再次感谢基思,你';你是个救生员
页:
[1]