0

I want to pass my input to other subs,something like:

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

I search for solution and read about ByVal or ByRef but i get confused where to put the variable, someone can help?

1 Answer 1

1
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
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.