简体   繁体   English

将字符串数组设置为组合框列表会在 Visual Basic 中给出 Argument is required 错误

[英]Setting String Array as Combobox List gives Argument is required error in Visual Basic

So I have a String array declared as this:所以我有一个字符串数组声明如下:

Dim astrSomethingList() As String: astrSomethingList = _ 
    Array("01", "02", "03", "04", "05", "06", "07", "08", "20")

And then I try to assign this array to a ComboBox I have in a form, like this:然后我尝试将这个数组分配给我有一个表单的 ComboBox,如下所示:

With m_form

    ...
    
    .cboQuerySomething.List = astrSomethingList

    ...
    
End With

But when I try to compile and run it, it gives me the error The argument is not optional and refers to the .List = part of the code.但是当我尝试编译并运行它时,它给了我错误The argument is not optional并且指的是代码的.List =部分。

I have tried using我试过使用

Set .cboQuerySomething.List = astrSomethingList

instead, but it does not work either.相反,但它也不起作用。

What am I missing?我错过了什么?

For VB6 Combo Boxes, first call .Clear and then loop through the values and use .Add on each item individually对于 VB6 组合框,首先调用.Clear然后遍历值并在每个项目上单独使用.Add

.List() in a VB6 Combobox is an indexed property, not a settable field. .List()在 VB6 组合框中是一个索引属性,而不是一个可设置的字段。 There is no way to set the entire list at once, but it would be simple to create a helper module with commonly executed tasks.没有办法一次设置整个列表,但是创建一个包含常用任务的帮助器模块会很简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM