You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Solidworks中VBA二维数组按Thickness(tableData(i,5))排序失败求助

问题描述

我尝试依据Thickness(对应tableData(i,5))对二维数组tableData进行排序,这段代码在Excel中运行正常,但在SolidWorks中无法实现排序。经检查发现Excel与SolidWorks中的循环迭代存在差异,以下是我的代码:

Dim temp0 As Double, temp1 As String, temp2 As Double, temp3 As String, temp4 As Double, temp5 As Double
    For i = 0 To UBound(tableData, 1) - 1
        For j = i + 1 To UBound(tableData, 1)
            If tableData(i, 5) < tableData(j, 5) Then ' kalınlık
                temp0 = tableData(j, 0)
                temp1 = tableData(j, 1)
                temp2 = tableData(j, 2)
                temp3 = tableData(j, 3)
                temp4 = tableData(j, 4)
                temp5 = tableData(j, 5)
                tableData(j, 0) = tableData(i, 0)
                tableData(j, 1) = tableData(i, 1)
                tableData(j, 2) = tableData(i, 2)
                tableData(j, 3) = tableData(i, 3)
                tableData(j, 4) = tableData(i, 4)
                tableData(j, 5) = tableData(i, 5)
                tableData(i, 0) = temp0
                tableData(i, 1) = temp1
                tableData(i, 2) = temp2
                tableData(i, 3) = temp3
                tableData(i, 4) = temp4
                tableData(i, 5) = temp5
            End If
        Next j
    Next i

相关截图:
操作界面截图
数组数据截图

内容的提问来源于stack exchange,提问作者mesyen

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.12 02:41:57