excel - 变量名不匹配但仍然有效
问题描述
我正在查看我工作中某人创建的文件,它具有以下内容:
Sub Inputs(zDOB As Date, zRetAge As Double, zRetDate As Date, zDOJ As Date, zEmployer As Double, zEmployee As Double, _
zSalary() As Double, zInflation As Double, zFund As Double, zAVCRate As Double, zEvalDate As Date, zAVCFund As Double, _
zCharge As Double, zFund2 As Double, zAVCFund2 As Double)
zDOB = Range("B1")
zRetAge = Range("B7")
zRetDate = Range("B8")
zDOJ = Range("B11")
zEmployer = Range("B15")
zEmployee = Range("B16")
zSalary(0) = Range("B14")
zInflation = Range("B19")
zFund = Range("B20")
zFund2 = Range("B20")
zAVCRate = Range("B24")
zAVCFund = Range("B27")
zAVCFund2 = Range("B27")
zEvalDate = Range("B6")
zCharge = Range("J7")
End Sub
很公平,这是设置稍后使用的输入。
我的问题是再次调用此子时:
Call Module3.Inputs(xDOfB, xRetirementAge, xDateRetire, xDOJ, xEmployer, xEmployee, xSalary, _
xInflation, xFund, xAVC, xEvalDate, xAVCFund, xCharge, xFund2, xAVCFund2)
z 现在是 x,这有什么不同吗?这是如何运作的?
解决方案
如果要跨下标使用公共变量,则可能需要使用它们。
Public zDOB As Variant
Public zRetAte As Variant
Sub textSub()
Call Inputs
End Sub
Sub Inputs()
zDOB = Range("B1")
zRetAge = Range("B7")
End Sub
推荐阅读
- microsoft-teams - Microsoft Teams - 更新选项卡 URL
- google-sheets - 按月份分组的数据透视表中的堆积条形图?
- reactjs - 在父组件的 onClick 上一次又一次地添加子组件,每次都使用新的道具到子组件
- verilog - 时钟域交叉信号和抖动要求
- email - 自定义域电子邮件不适用于 Heroku
- newrelic - Quarkus 原生容器中的 Newrelic 支持
- emacs - 将光标定位在 yasnippet 中的指定位置
- keras - ValueError:输入数组应具有与目标数组 LSTM Keras 相同数量的样本
- java - Java“空指针异常” - responseEntity.getBody().isNull()
- c++ - 字符串数组C ++中的字符识别不正确