title: Set VBA Variable to Result from Function which is String
body: <p>I've read a bunch about functions today and they all seem to deal with math/numbers. I'm trying to use a function which returns a string and capture that as a variable in the "main sub" but I can't get it to work. Can anybody point out what I'm doing wrong?</p>
  
  <p>Eg:</p>
  
  <p><strong>Function:</strong></p>
  
  <pre><code>Public Function Test(var) As Variant
   Bar = var &amp; "World"
   MsgBox Bar
  End Function
  </code></pre>
  
  <p><strong>Sub:</strong></p>
  
  <pre><code>Public Bar As Variant
  Public Z As Variant
  Sub testing()
   Call Test("Hello") ' This displays "HelloWorld" from MsgBox in Function 
   Test ("Hello")     ' This displays "HelloWorld" from MsgBox in Function 
   Z = Test("Hello")  ' This displays "HelloWorld" from MsgBox in Function 
   MsgBox Z           ' This displays an empty MsgBox :*(
  End Sub
  </code></pre>