[Gambas-user] Gambas3, Byref is not working

Demosthenes Koptsis demosthenesk at ...626...
Mon Jan 3 12:59:11 CET 2011


oops i found it.

i had to do this

  IncrementVariable2(ByRef Number1)


On Mon, 2011-01-03 at 12:35 +0100, Benoît Minisini wrote:
> > 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 ?
> 

-- 
Regards,
Demosthenes Koptsis.





More information about the User mailing list