注册 登录
编程论坛 VB.NET论坛

无法更改数组的维数

vbcaonia 发布于 2023-04-05 13:00, 539 次点击


下面这段程序中的:ReDim sj(1, add - 1)与ReDim Preserve sj(1, UBound(sj, 2) + add)都显示:无法更改数组的维数,应怎样修改,谢谢!



Private Sub Button10_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button10.Click


        Dim sj() As Long
        Dim dn As Long
        Dim sjStr() As String
        Dim str
        Dim add As Integer
        
        add = 300
        dn = 0
        ReDim sjStr(add - 1)
        ReDim sj(1, add - 1)

        For b = 1 To Rows-1
            With Me.AxfpSpread1
                .Row = b
                .Col = 1
                'Value数值,Text文本
                str = .Value
            End With

            If str <> "" Then
                If dn > UBound(sjStr) Then
                    ReDim Preserve sjStr(UBound(sjStr) + add)
                    ReDim Preserve sj(1, UBound(sj, 2) + add)
                End If
                sjStr(dn) = str
            End If
        Next b

        
    End Sub





[此贴子已经被作者于2023-4-5 18:25编辑过]

2 回复
#2
jian48922023-04-05 22:11
Dim sj(,) As Long
#3
vbcaonia2023-04-05 22:47
回复 2楼 jian4892
帮我解决了一个大问题,谢谢!
1