无法设置列表属性。属性值无效

发布于 2024-12-11 09:55:45 字数 2294 浏览 0 评论 0原文

我收到此错误,但我不知道原因。 我有以下代码:

Private Sub repereche_Change()
Dim ws As Worksheet
Set ws = Worksheets("BD_IR")
Dim Rand As Long, Rand2 As Long
Dim prestrangere As Long
Dim prestrangere2 As Long
Dim bila As Long
Dim ws2 As Worksheet
Set ws2 = Worksheets("BD_AR")
prestrangere = 0
prestrangere2 = 0
bila = 10
Rand = 3
Rand2 = 3

Do While ws.Cells(Rand, 3).Value <> "" And Rand < 65000
    If Me.repereche.Value = Mid(ws.Cells(Rand, 3), 4, 10) Then
        Do While ws2.Cells(Rand2, 3).Value <> "" And Rand2 < 65000
            If Me.repereche.Value = Mid(ws2.Cells(Rand2, 3), 4, 10) Then
                If ws.Cells(Rand, 7) <> "" Then
                prestrangere = (((ws2.Cells(Rand2, 7) - 400) * 10) - ((ws.Cells(Rand, 6) - 400) * 10) - (bila * 1.414 * 2)) - 10
                prestrangere2 = (((ws2.Cells(Rand2, 6) - 400) * 10) - ((ws.Cells(Rand, 7) - 400) * 10) - (bila * 1.414 * 2)) - 10
                Else
                prestrangere = (((ws2.Cells(Rand2, 6) - 400) * 10) - ((ws.Cells(Rand, 6) - 400) * 10) - (bila * 1.414 * 2)) - 10
                End If
                gksluri.AddItem ws.Cells(Rand, 4).Value 'comanda IR
                gksluri.List(gksluri.ListCount - 1, 1) = ws.Cells(Rand, 5) 'inel IR
                gksluri.List(gksluri.ListCount - 1, 2) = ws.Cells(Rand, 6) 'GKSL IR
                gksluri.List(gksluri.ListCount - 1, 3) = ws.Cells(Rand, 7) 'GKSL 2 IR
                gksluri.List(gksluri.ListCount - 1, 4) = ws2.Cells(Rand2, 4) 'comanda AR
                gksluri.List(gksluri.ListCount - 1, 5) = ws2.Cells(Rand2, 5) 'inel AR
                gksluri.List(gksluri.ListCount - 1, 6) = ws2.Cells(Rand2, 6) 'GKSL AR
                gksluri.List(gksluri.ListCount - 1, 7) = ws2.Cells(Rand2, 7) 'GKSL 2 AR
                gksluri.List(gksluri.ListCount - 1, 8) = bila
                gksluri.List(gksluri.ListCount - 1, 9) = prestrangere
                gksluri.List(gksluri.ListCount - 1, 10) = "test" 'HERE IS THE ERROR
            End If
        Rand2 = Rand2 + 1
        Loop
    End If
Rand2 = 3
Rand = Rand + 1
Loop
End Sub

gksluri 是一个列表框。列表框在 ColumnCount 属性中设置了 11 列。如果我删除该线,

gksluri.List(gksluri.ListCount - 1, 10) = "test" 

它就可以正常工作。我做错了什么?问题可能出在哪里?我什么也没找到。 多谢!

I'm getting this error and I don't know the reason.
I have the following piece of code:

Private Sub repereche_Change()
Dim ws As Worksheet
Set ws = Worksheets("BD_IR")
Dim Rand As Long, Rand2 As Long
Dim prestrangere As Long
Dim prestrangere2 As Long
Dim bila As Long
Dim ws2 As Worksheet
Set ws2 = Worksheets("BD_AR")
prestrangere = 0
prestrangere2 = 0
bila = 10
Rand = 3
Rand2 = 3

Do While ws.Cells(Rand, 3).Value <> "" And Rand < 65000
    If Me.repereche.Value = Mid(ws.Cells(Rand, 3), 4, 10) Then
        Do While ws2.Cells(Rand2, 3).Value <> "" And Rand2 < 65000
            If Me.repereche.Value = Mid(ws2.Cells(Rand2, 3), 4, 10) Then
                If ws.Cells(Rand, 7) <> "" Then
                prestrangere = (((ws2.Cells(Rand2, 7) - 400) * 10) - ((ws.Cells(Rand, 6) - 400) * 10) - (bila * 1.414 * 2)) - 10
                prestrangere2 = (((ws2.Cells(Rand2, 6) - 400) * 10) - ((ws.Cells(Rand, 7) - 400) * 10) - (bila * 1.414 * 2)) - 10
                Else
                prestrangere = (((ws2.Cells(Rand2, 6) - 400) * 10) - ((ws.Cells(Rand, 6) - 400) * 10) - (bila * 1.414 * 2)) - 10
                End If
                gksluri.AddItem ws.Cells(Rand, 4).Value 'comanda IR
                gksluri.List(gksluri.ListCount - 1, 1) = ws.Cells(Rand, 5) 'inel IR
                gksluri.List(gksluri.ListCount - 1, 2) = ws.Cells(Rand, 6) 'GKSL IR
                gksluri.List(gksluri.ListCount - 1, 3) = ws.Cells(Rand, 7) 'GKSL 2 IR
                gksluri.List(gksluri.ListCount - 1, 4) = ws2.Cells(Rand2, 4) 'comanda AR
                gksluri.List(gksluri.ListCount - 1, 5) = ws2.Cells(Rand2, 5) 'inel AR
                gksluri.List(gksluri.ListCount - 1, 6) = ws2.Cells(Rand2, 6) 'GKSL AR
                gksluri.List(gksluri.ListCount - 1, 7) = ws2.Cells(Rand2, 7) 'GKSL 2 AR
                gksluri.List(gksluri.ListCount - 1, 8) = bila
                gksluri.List(gksluri.ListCount - 1, 9) = prestrangere
                gksluri.List(gksluri.ListCount - 1, 10) = "test" 'HERE IS THE ERROR
            End If
        Rand2 = Rand2 + 1
        Loop
    End If
Rand2 = 3
Rand = Rand + 1
Loop
End Sub

gksluri is a Listbox. The Listbox has 11 columns set at the ColumnCount property. If I remove the line

gksluri.List(gksluri.ListCount - 1, 10) = "test" 

it works ok. What am I doing wrong? Where could the problem be? I couldn't find anything.
Thanks a lot!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

薄荷港 2024-12-18 09:55:45

对于未绑定的数据源,有 10 列限制(0 到 9)。

来自: http://office.microsoft.com/en-us/excel -帮助/HV080556371.aspx

For an unbound data source, there is a 10-column limit (0 to 9).

From: http://office.microsoft.com/en-us/excel-help/HV080556371.aspx

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文