如何解决程序是否成功结束时在文本框中显示消息
我有下面的代码,当它运行更新 14 个表时,想知道如何使用下面模板中的文本框显示 msg 显示订阅是否成功结束。
[Private Sub Command0_Click()
'Sub 1
A_Forecast
'Text Box showing the msg OK or Failed
A_ForecastTxt "OK" or "Not"
'Sub 2
B_Forecast
'Text Box showing the msg OK or Failed
B_ForecastTxt "OK" or "Not"
End Sub][1]
解决方法
把 subs 变成 functions 因为它们可以返回一个值:
Private Sub Command0_Click()
Dim Success As Boolean
' Function 1
Success = A_Forecast
' Text box showing the msg OK or failed
MsgBox IIf(Success,"OK","Failed")
' Function 2
Success = B_Forecast
' Text box showing the msg OK or failed
MsgBox IIf(Success,"Failed")
End Sub
示例:
Public Function A_Forecast() As Currency
Dim Result As Currency
Dim Something As Boolean
' Your code:
Something = True ' or False
If Something = True Then
Result = 100
Else
Result = 200
End If
A_Forecast = Result
End Function
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。