我在VBA中有一个FORM和MODULE。当宏运行时,显示表单(frmQuestions),数据输入文本框(txtName)和下拉(lstChoose)。当用户按下命令按钮(cmdEnter)时,如何将txtName中的数据和lstChoose传递给模块?
答案 0 :(得分:1)
要将表单上的事件数据传递给模块中包含的函数,请执行以下操作:
frmQuestions
表格中包含的点击事件代码:
Private Sub cmdEnter_Click()
Dim TempReturnVal as Boolean
TempReturnVal = funUpdateRecords(txtName.value, lstChoose.value)
End Sub
模块中的功能:
Public Function funUpdateRecords(funName As String, funChoice As String) As Boolean
' Do whatever it is that you want to
'funName contains the value of txtName
'funChoice contains the value of lstChoose
'Return True if successful or False if not.
funUpdateRecords = True
End Function