{{fbdoc item="title" value="BYREF (parameters)"}}----
Declaration specifier to explicitly pass a parameter by reference

{{fbdoc item="syntax"}}##
	**Byref** //param// [[KeyPgAs as]] [[DataType datatype]]
##
{{fbdoc item="usage"}}##
	[ [[KeyPgDeclare declare]] ] { [[KeyPgSub sub]] | [[KeyPgFunction function]] } //proc_name// ( **Byref** //param// [[KeyPgAs as]] [[DataType datatype]]  )
##
{{fbdoc item="desc"}}
	Passes a variable by reference, that is its address, to a subroutine or function. When a variable is passed by reference, the contents of the variable can be changed by the target subroutine or function.
	
	In //[[CompilerOptlang -lang qb]]// and //[[CompilerOptlang -lang fblite]]// dialects, ##**Byref**## is the default parameter passing convention, unless ##[[KeyPgOptionbyval Option ByVal]]## is in effect.

	Opposite of ##[[KeyPgByval ByVal]]##.

{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/procs/byref.bas"}}%%(freebasic)
dim MyVar as integer

sub ChangeVar(byref AVar as integer)
	AVar = AVar + 1
end sub

MyVar = 1
print "MyVar: "; MyVar 'output = 1
ChangeVar MyVar
print "MyVar: "; MyVar 'output = 2
sleep
end
%%

{{fbdoc item="lang"}}
	- In //[[CompilerOptlang -lang fb]]// dialect, ##**Byval**## is the default parameter passing convention for all built-in types except ##[[KeyPgString String]]## and user-defined ##[[KeyPgType Type]]## which are passed ##[[KeyPgByref Byref]]## by default.
	- In //[[CompilerOptlang -lang qb]]// and //[[CompilerOptlang -lang fblite]]// dialects, ##**Byref**## is the default parameter passing convention.

{{fbdoc item="diff"}}
	- New to ""FreeBASIC""

{{fbdoc item="see"}}
	- [[ProPgPassingArguments Passing Arguments to Procedures]]
	- ##[[KeyPgDeclare Declare]]##
	- ##[[KeyPgByval ByVal]]##
	- ##[[KeyPgByrefFunction Byref (function results)]]##

{{fbdoc item="back" value="CatPgProcedures|Procedures"}}