3

Okay I want to add something to this macro

Sub Search()
  Inputbox myInput                      
  found = false
  loop
     Call getInput (myInput)            '~> check multiple files
  end loop
  If found = false
    'DO something   
  End if
End sub

Sub getInput(ByVal inputVar As String, ByVal Input as Boolean)
  If a = inputVar Then                  
      found = true                      '~> I want to pass this parameter back to search
  End If
End sub

The case is like, I want my sub to pass the found parameter from Search() to getInput() and then getInput() return the found parameter to Search()

Should I add something like search(ByVal found as boolean) ?

2
  • what is a in your getInput Sub? and your loop syntax is invalid.. Commented Nov 23, 2013 at 18:20
  • 2
    Function can return values. Have you tried them out? Commented Nov 23, 2013 at 18:22

1 Answer 1

4

if you want to return a value, then you should change the getInput Sub to a function as they can return values.

Sub Search()
  Dim found As Boolean

  InputBox myInput

  found = checkInput(myInput)

  If found = False Then
    'DO something
  End If
End Sub

Function checkInput(inputVar As String) As Boolean

    Dim result As Boolean

    'do your checking here and set result

    'return the result
    checkInput = result

End Function
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.