vba excel在子系统之间传递参数

vba excel在子系统之间传递参数,vba,Vba,我想将我的输入传递给其他SUB,例如: Sub Search() Inputbox myInput '~> this is the variable I want to pass Call getInput '~> I want to pass the variable to this sub End sub Sub getInput() if a = myInput '~> from sub Search() DO something

我想将我的输入传递给其他SUB,例如:

Sub Search()
  Inputbox myInput   '~> this is the variable I want to pass
  Call getInput      '~> I want to pass the variable to this sub
End sub

Sub getInput()
  if a = myInput     '~> from sub Search()
  DO something
End sub
我寻找解决方案并阅读了关于ByVal或ByRef的内容,但我不知道该将变量放在哪里,有人能帮我吗

Sub Search()
  Inputbox myInput   '~> this is the variable I want to pass
  Call getInput (myInput)  '~> Note the variable
End sub

Sub getInput(ByVal inputVar As String)  '~> Note:  You need to specify the datatype
  If a = inputVar Then     '~> Use your parameter here
      'DO something
  End If
End sub