【发布时间】:2021-09-24 06:28:03
【问题描述】:
我正在尝试从用户表单中的列表框中存储用户选择。我目前正在使用公共属性 get 从另一个模块的用户表单中检索我的值。
这是在我的用户表单中:
Public Property Get DateFrom() As String
DateFrom = TextBox1.Text
End Property
Public Property Get DateTo() As String
DateTo = TextBox2.Text
End Property
Public Property Get Cost() As String
Cost = TextBox3.Text
End Property
Public Property Get Expense() As String
Expense = TextBox4.Text
End Property
从另一个模块调用时会起作用
Sub FormNLReport()
With New NLTrans
.Show vbModal
On Error GoTo CloseF
NLReport .DateFrom, .DateTo, .Cost, .Expense
CloseF: Unload NLTrans
Exit Sub
End With
End Sub
然后链接到这个子类:
Sub NLReport(DateFrom As String, DateTo As String, Cost As String, Expense As String)
但是,我现在想添加一个多选列表框,但对如何将其从用户窗体传递到模块感到困惑。目前我已经这样做了:
Public Property Get Items(ByRef i As Long) As String
For i = 0 To ListBox1.ListCount - 1
If ListBox1.Selected(i) = True Then
Items(i) = ListBox1.List(i)
MsgBox (Items(i))
End If
Next i
End Property
我的另一个模块:
Sub FormNLReport()
With New NLTrans
.Show vbModal
On Error GoTo CloseF
NLReport .DateFrom, .DateTo, .Cost, .Expense, .Items()
CloseF: Unload NLTrans
Exit Sub
End With
End Sub
Sub NLReport(DateFrom As String, DateTo As String, Cost As String, Expense As String, Items() As String)
然后当我尝试从另一个模块调用它时,我得到一个错误:
【问题讨论】: