我在 VBA 中有一个 FORM 和 MODULE。运行宏时,会显示表单 (frmQuestions),将数据输入到文本框 (txtName) 和下拉菜单 (lstChoose)。当用户按下命令按钮(cmdEnter)时,如何将 txtName 和 lstChoose 中的数据传递给模块?
问问题
1350 次
1 回答
1
要将表单上的事件中的数据传递给模块中包含的函数,请执行以下操作:
表单中包含的On Click事件代码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
于 2013-09-26T18:12:13.440 回答