excel - 将输入框变量从一个子传递到另一个
问题描述
我正在阅读另一个不需要全球声明的帖子。
我有一个 Sub 要求用户输入一个值,在另一个 Sub 中,我使用输入的值根据他们的输入调用其他 Sub。
我在我的例子中很接近吗?谢谢
Option Explicit
Sub MonthTest()
Dim strMonth As String
strMonth = InputBox("enter Area here")
Call Test2
End Sub
Sub Test2(strMonth As String)
Select Case strMonth
Case Is = "82"
Call Area82
Case Is = "80"
Call Area80
End Select
End Sub
解决方案
您必须将变量提供给调用函数,否则它不知道在哪里寻找它。
更改:调用 Test2 为:调用 Test2 strMonth
推荐阅读
- python - python ctypes和C++指针
- javascript - 我可以选择一个类型的所有反应组件,而不为每个组件分配一个类吗?
- ajax - 如何使用 jQuery Ajax 访问 Twitter API?
- python - 字节格式的Python列表如何转换为常规列表
- sql - 在 Dynamic Query 中的 SQL Server 中从字符串到日期时间的转换失败
- linux - 在 shell 脚本中迭代地打印特定格式的文件数
- php - 带有 php codeigniter 的 Bootstrap 4 动态导航药丸不起作用
- javascript - 由于 javascript,Selenium 选择了错误的下拉选项
- amazon-web-services - Amazon Athena 中的重复值
- css - 如何用图片替换 WordPress 页面标题?