Hi all this is my first question. I'm trying to populate my combobox (named "ComboBox1") in my userform. However, I'm having trouble getting this simple task accomplished. Here's my code:
大家好,这是我的第一个问题。我正在尝试在我的用户表单中填充我的组合框(名为“ComboBox1”)。但是,我很难完成这个简单的任务。这是我的代码:
Private Sub Form_Load(menu)
Dim i As Integer
For i = 0 To 28
Me.ComboBox1.AddItem menu(i, 0, 0)
Next i
End Sub
menu
is a 3d array where menu((0 to 28), 0 ,0)
are strings of dates in April. However, vba isn't adding them into my combo box. Could anyone should some light on this matter?
menu是一个3d数组,其中menu((0到28),0,0)是四月份的日期字符串。但是,vba不会将它们添加到我的组合框中。任何人都应该对此事有所了解吗?
1 个解决方案
#1
1
That is most probably because you are not calling the Form_Load(menu)
这很可能是因为你没有调用Form_Load(菜单)
This works for me.
这对我有用。
Dim menu(0 To 28, 0, 0)
Dim i As Long
Private Sub CommandButton1_Click()
For i = 0 To 28
menu(i, 0, 0) = "Sid" & (i + 1)
Next i
Form_Load menu
End Sub
Private Sub Form_Load(menu)
For i = 0 To 28
Me.ComboBox1.AddItem menu(i, 0, 0)
Next i
End Sub
#1
1
That is most probably because you are not calling the Form_Load(menu)
这很可能是因为你没有调用Form_Load(菜单)
This works for me.
这对我有用。
Dim menu(0 To 28, 0, 0)
Dim i As Long
Private Sub CommandButton1_Click()
For i = 0 To 28
menu(i, 0, 0) = "Sid" & (i + 1)
Next i
Form_Load menu
End Sub
Private Sub Form_Load(menu)
For i = 0 To 28
Me.ComboBox1.AddItem menu(i, 0, 0)
Next i
End Sub