Get variable from method caller

How do you set the variable of the method caller from within the method. I know that I could pass the variable as a parameter but is there a faster way of doing it?

For example:
Sub MethodCaller
dim int as integer 'declared variable that is only accesible from this method
call Method
End Sub

Sub Method
int = 12
End Sub

'I know that you can just write this:
Sub MethodCaller
dim int as integer 'declared variable that is only accesible from this method
int=Method
End Sub

Sub Method (int as integer)
int = 12
End Sub

'But would it not be more efficient for me writing the code and the computer if I was declare a variable that was only accessible to the method it is declared within and method calls from within that

You probably will not understand what I am trying to ask because it is seem crazy and overly obsessed. You may understand if you take that in mind.

Thanks

It IS crazy and obsessed. Well, a bit.

I’ve only seen this matter when I have to pass around large strings.

You can use ‘ByRef’ for the parameter:

[code]Sub MethodCaller
dim int as integer 'declared variable that is only accesible from this method
call Method(int)
End Sub

Sub Method(ByRef int as integer)
int = 12
End Sub
[/code]
although I prefer using the return value (which, btw in your second example wouldn’t work as you expect since you are setting the value of the local variable ‘int’, but not returning the value from ‘Method’).

[code]Sub MethodCaller
dim int as integer 'declared variable that is only accesible from this method
int = Method()
End Sub

Sub Method()
Dim int as integer
int = 12
return int
End Sub
[/code]

Another option to achieve this would be to create a class that contains your two methods. Then you can add a private property to the class that will be accessible by all the methods on the class but not available to code outside the class.

Sorry. I know this was a while back but I forgot to say thankyou. So here is my thanks.