乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
查看: 118|回复: 6

[编程交流] VB排序文本屏幕同上

[复制链接]

3

主题

5

帖子

2

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-6 22:10:27 | 显示全部楼层 |阅读模式
你好
在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
下一个
 
末端接头
回复

使用道具 举报

1

主题

1069

帖子

1050

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
69
发表于 2022-7-6 22:29:05 | 显示全部楼层
尝试以下代码,然后根据需要重写此示例:
 
  1. Option Explicit
  2. Option Compare Binary 'working with 'Option Compare Text' as well
  3.   Sub BubbleSort(arr As Variant, Optional descending As Boolean, Optional numEls As Variant)
  4.           ' Bubble Sort an array of any type
  5.           ' Author: The VB2TheMax Team
  6.           ' BubbleSort is especially convenient with small  arrays (1,000
  7.           ' items or fewer) or with arrays that are  already almost sorted
  8.           '
  9.           ' NUMELS is the index of the last item to be sorted, and is
  10.           ' useful if the array is only partially filled.
  11.           '
  12.           ' Works with any kind of array, except UDTs and fixed -Length
  13.           ' strings, and including objects if your are sorting on their
  14.           ' default property. String are sorted in case-sensitive mode.
  15.           '
  16.           ' You can write faster procedures if you modify the first two lines
  17.           ' to account for a specific data type, eg.
  18.            'Sub BubbleSortS(arr() As Single, Optional descending As Boolean, Optional numEls As Variant)
  19.           ' Dim value As Single
  20.           Dim Value As Variant
  21.           Dim Index As Long
  22.           Dim firstItem As Long
  23.           Dim indexLimit As Long, lastSwap As Long
  24.           ' account for optional arguments
  25.           If IsMissing(numEls) Then numEls = UBound(arr)
  26.           firstItem = LBound(arr)
  27.           lastSwap = numEls
  28.           Do
  29.           indexLimit = lastSwap - 1
  30.           lastSwap = 0
  31.           For Index = firstItem To indexLimit
  32.           Value = arr(Index)
  33.           If (Value > arr(Index + 1)) Xor descending Then
  34.           ' if the items are not in order, swap them
  35.           arr(Index) = arr(Index + 1)
  36.           arr(Index + 1) = Value
  37.           lastSwap = Index
  38.           End If
  39.           Next
  40.           Loop While lastSwap
  41.           End Sub
  42.          
  43.          
  44.          Sub testSort()
  45.          Dim strText As String
  46.          
  47.          Dim Items(3) As Variant
  48.          Dim i
  49.          Items(0) = "handle N°3"
  50.          Items(1) = "handle N°1"
  51.          Items(2) = "handle N°2"
  52.          Items(3) = "handle N°4"
  53.          
  54.          '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
  55.          'Sort array by descending:
  56.          BubbleSort Items, False
  57.          '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~'
  58.          
  59.          For i = LBound(Items) To UBound(Items)
  60.          Debug.Print Items(i)
  61.          Next i
  62.          End Sub
回复

使用道具 举报

12

主题

175

帖子

77

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
149
发表于 2022-7-6 22:36:28 | 显示全部楼层
精细分类子修复。
 
我还发布了acad386bis问题的可能解决方案http://forums.autodesk.com/t5/Visual-Basic-Customization/VBA-tri-le-TXT-in-bloc-dans-listbox-idem-bloc-%C3%A9cran/td-第4855179页
在这里,我使用了一个排序子来管理矩阵,而不是为更广泛的用途而开发的数组。
但我肯定会加强你的想法
谢谢
 
再见
回复

使用道具 举报

1

主题

1069

帖子

1050

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
69
发表于 2022-7-6 22:46:17 | 显示全部楼层
很棒的工作,
感谢您的解决方案
干杯
回复

使用道具 举报

3

主题

5

帖子

2

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-6 22:55:44 | 显示全部楼层
块文本排序。拉链
 
文件附件不好看吗
回复

使用道具 举报

12

主题

175

帖子

77

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
149
发表于 2022-7-6 23:06:16 | 显示全部楼层
收到您的请求后,我附上修订版
 
我将文本插入保存在“text”矩阵第一列的点“Y”坐标上,而不是“handle”属性。然后我要求dhBubbleSort2D按第一列排序(并添加了升序/降序排序顺序参数)
 
再见
块文本排序rev 10_03_2014 RICVBA。图纸
回复

使用道具 举报

3

主题

5

帖子

2

银币

初来乍到

Rank: 1

铜币
15
发表于 2022-7-6 23:16:17 | 显示全部楼层
RICVBA谢谢!
 
 
 
 
这个论坛太酷了。。。
代码真的很漂亮,读起来很有趣。
最终结果并不复杂
再次感谢你
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-4 11:40 , Processed in 0.639037 second(s), 66 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表