Option ByVal

FreeBASIC

Option ByVal
 
Specifies parameters are to be passed by value by default in procedure declarations

Syntax

Option ByVal

Description

Option ByVal is a statement that sets the default passing convention for procedure parameters to by value, as if declared with ByVal. This default remains in effect for the rest of the module in which Option ByVal is used, and can be overridden by specifying ByRef in parameter lists.

Example

'' compile with the "-lang fblite" compiler switch

#lang "fblite"

Sub TestDefaultByref( a As Integer )
  '' change the value
  a = a * 2
End Sub

Option ByVal

Sub TestDefaultByval( a As Integer )
  a = a * 2
End Sub

Dim a As Integer = 1

Print "a = "; a
TestDefaultByref( a )
Print "After TestDefaultByref : a = "; a
Print

Print "a = "; a
TestDefaultByval( a )
Print "After TestDefaultByval : a = "; a
Print


Dialect Differences

Differences from QB

  • New to FreeBASIC

See also