VB排序文本屏幕同上
你好在autocad block 4 line TXT中
TXT1(手柄#3)
TXT2(手柄#2)
TXT3(4号手柄)
TXT4(手柄#1)
当我在组合框中重复使用字符串时,它将按句柄顺序排列
TXT4,2,1,3
然后我想按行屏幕TXT1,2,3,4的顺序
谢谢你的帮助
********
你好
Dans le bloc autocad 4 Alignes de TXT
TXT1(手柄3)
TXT2(手柄2)
TXT3(4号手柄)
TXT4(手柄1)
Quand je recupere le string dans une combobox il me le met dans l'ordre du handle=>Ligne 4,2,1,3
alors que je je veux dans l'ordre de lécran ligne 1,2,3,4
谢谢你的帮助
公共子LireTxt()
Dim objBloc作为AcadBlock
Dim objEnt As AcadEntity模糊对象
Dim objentText作为AcadText
此图纸。公用事业GetEntity objBlocRef,Pt1,“Sélectionnez le blocá修饰符:”
设置objBloc=ThisDrawing。块(objBlocRef.Name)
对于objBloc中的每个objEnt
如果是objEnt。ObjectName=“AcDbText”然后
ListBoxTxt。AddItem objentText。文本字符串
Endif
下一个
末端接头 尝试以下代码,然后根据需要重写此示例:
Option Explicit
Option Compare Binary 'working with 'Option Compare Text' as well
Sub BubbleSort(arr As Variant, Optional descending As Boolean, Optional numEls As Variant)
' Bubble Sort an array of any type
' Author: The VB2TheMax Team
' BubbleSort is especially convenient with smallarrays (1,000
' items or fewer) or with arrays that arealready almost sorted
'
' NUMELS is the index of the last item to be sorted, and is
' useful if the array is only partially filled.
'
' Works with any kind of array, except UDTs and fixed -Length
' strings, and including objects if your are sorting on their
' default property. String are sorted in case-sensitive mode.
'
' You can write faster procedures if you modify the first two lines
' to account for a specific data type, eg.
'Sub BubbleSortS(arr() As Single, Optional descending As Boolean, Optional numEls As Variant)
' Dim value As Single
Dim Value As Variant
Dim Index As Long
Dim firstItem As Long
Dim indexLimit As Long, lastSwap As Long
' account for optional arguments
If IsMissing(numEls) Then numEls = UBound(arr)
firstItem = LBound(arr)
lastSwap = numEls
Do
indexLimit = lastSwap - 1
lastSwap = 0
For Index = firstItem To indexLimit
Value = arr(Index)
If (Value > arr(Index + 1)) Xor descending Then
' if the items are not in order, swap them
arr(Index) = arr(Index + 1)
arr(Index + 1) = Value
lastSwap = Index
End If
Next
Loop While lastSwap
End Sub
Sub testSort()
Dim strText As String
Dim Items(3) As Variant
Dim i
Items(0) = "handle N°3"
Items(1) = "handle N°1"
Items(2) = "handle N°2"
Items(3) = "handle N°4"
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
'Sort array by descending:
BubbleSort Items, False
'~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
For i = LBound(Items) To UBound(Items)
Debug.Print Items(i)
Next i
End Sub 精细分类子修复。
我还发布了acad386bis问题的可能解决方案http://forums.autodesk.com/t5/Visual-Basic-Customization/VBA-tri-le-TXT-in-bloc-dans-listbox-idem-bloc-%C3%A9cran/td-第4855179页
在这里,我使用了一个排序子来管理矩阵,而不是为更广泛的用途而开发的数组。
但我肯定会加强你的想法
谢谢
再见 很棒的工作,
感谢您的解决方案
干杯 块文本排序。拉链
文件附件不好看吗 收到您的请求后,我附上修订版
我将文本插入保存在“text”矩阵第一列的点“Y”坐标上,而不是“handle”属性。然后我要求dhBubbleSort2D按第一列排序(并添加了升序/降序排序顺序参数)
再见
块文本排序rev 10_03_2014 RICVBA。图纸 RICVBA谢谢!
这个论坛太酷了。。。
代码真的很漂亮,读起来很有趣。
最终结果并不复杂
再次感谢你
页:
[1]