当前位置: 首页 > news >正文

Application.OnTime如何引用带参数的过程

        Application.OnTime方法本身并不直接支持传递参数给被调用的过程。不过,有几种方法可以间接实现这个需求。

        方法1:使用单引号表达式
        使用单引号表达式来传递参数时,不能在表达式中使用变量,需要把参数值直接写到表达中,注意在表达中一个双引号需要用两个来表示,例如:

Sub test()Application.OnTime Now + TimeValue("00:00:00"), "'MySub ""Hellow! "",""Jim""'"
End SubSub MySub(strA As String, strB As String)MsgBox strA & vbCrLf & strB
End Sub

        方法2:使用全局变量
        你可以使用全局变量来传递参数,例如:

Public strA As String, strB As String
Sub test()strA = "Hellow! "strB = "Jim"Application.OnTime Now + TimeValue("00:00:00"), "MySub"
End SubSub MySub()MsgBox strA & vbCrLf & strB
End Sub

        方法3:使CALL方法
        使用CALL方法来传递参数的需要新增一个子过程,例如:

Sub test()Application.OnTime Now + TimeValue("00:00:00"), "MyVar"
End SubSub MyVar()Dim strA As String, strB As StringstrA = "Hellow! "strB = "Jim"Call MySub(strA, strB)
End SubSub MySub(strA As String, strB As String)MsgBox strA & vbCrLf & strB
End Sub

        以上方法选择哪一种取决于你的具体需求和场景。


http://www.mrgr.cn/news/94009.html

相关文章:

  • 记录--有惊无险
  • 数据结构全解析:从线性到非线性,优缺点与应用场景深度剖析
  • 大模型在甲状腺良性肿瘤诊疗全流程中的应用研究报告
  • Nginx 监控方法(‌Nginx Monitoring Methods)
  • LearnOpenGL-笔记-其二
  • 【从零开始学习计算机科学】操作系统(八)IO管理
  • 大模型在甲状腺癌诊疗全流程预测及方案制定中的应用研究
  • Excel 中如何实现数据透视表?
  • 【Pandas】pandas Series asfreq
  • 如何通过强化学习RL激励大型语言模型(LLMs)的搜索能力?R1-Searcher来了
  • 指令微调 (Instruction Tuning) 与 Prompt 工程
  • ubuntu 22.04 本地部署DeepSeek的Janus Pro
  • Go语言Viper配置详解:conf库优雅解析实战
  • 电路原理(电容 集成电路NE555)
  • 知乎后台管理系统:数据库系统原理实验1——数据库基础概念
  • 每日一题----------String 和StringBuffer和StringBuiler重点
  • linux 系统 之centos安装 docker
  • 1.1 双指针专题:移动零(easy)
  • Dify平台部署全记录
  • WinForm模态与非模态窗体