r/visualbasic • u/SpecyTwat67 • Mar 25 '20
How to print/call a variable from a function in a sub.
So I have a quadratic equation function which prints 2 variables xpos and xneg. How do I call those two in another sub.
5
Upvotes
1
u/f15sim Mar 26 '20
Instead of defining a structure as a return value, you could pass the xpos and xneg by reference.
Look at the help for the ByRef keyword. It allows you to build a function (or subroutine for that matter) that "returns" more than one value.
2
u/JasonHenley Mar 25 '20
Could you give more context? There are a few ways variables are passed around. One is by a return value from a function:
Here's how you pass a variable to a sub:
Another way is by global variable but this is usually the least desirable option: