[Gambas-user] Gambas3, Byref is not working

Benoît Minisini gambas at ...1...
Mon Jan 3 12:35:38 CET 2011


> Hi,
> 
> i made an example for BYREF but it is not working
> 
> --------------------------------
> ' Gambas class file
> 
> Public Sub Form_Open()
> 
>   Dim Number1 As Integer
> 
>   Number1 = 10
> 
>   IncrementVariable1(Number1)
> 
>   Print Number1
> 
>   IncrementVariable2(Number1)
> 
>   Print Number1
> 
> End
> 
> Private Sub IncrementVariable1(Num1 As Integer)
>   'ByVal sub
>   Num1 = Num1 + 1
> 
> End
> 
> Private Sub IncrementVariable2(ByRef Num2 As Integer)
>   'ByRef sub
> 
>   Num2 = Num2 + 1
> 
> End
> --------------------------------
> result:
> 10
> 10 <- this shouldn't be 11?

Did you read the documentation on ByRef ?

-- 
Benoît Minisini




More information about the User mailing list