Return variables to main

2 posts / 0 new
Last post
lucas79
Offline
Joined: 05/24/2019 - 12:50
Return variables to main

Hello, 
I have a question, i have a script with main and functions, so i can't return variable of function to main. It is possible? 
For example:
"MAIN"
......
var_return = Call custom_function1
.....
///////////////////////////////////////////////////////////////////////////////////////////////////
Function custom_function1
.....
....
Return var1
End function
Thank you!

Brian Element's picture
Brian Element
Offline
Joined: 07/11/2012 - 19:57

Yes it is possible, you need to make the return value equal to the function name.  Also in your call you don't need the call key word.  Here is an example for you:


option explicit

Sub Main
	Dim var_return  As String
	var_return = custom_function1()
	MsgBox var_return
End Sub

Function custom_function1() As String
	'to return a value make it equal to the function name
	custom_function1 = "This is the return value" 
End Function