[Gambas-user] Leavng a SUB

Fabien Gambasfr at ...11...
Tue Jun 24 20:45:27 CEST 2003


Le Mardi 24 Juin 2003 15:42, Henry Ismaili a écrit :
> Is this the way it's supposed to be done ...
>
> PUBLIC SUB Button2_Click()
>
>   IF textbox1.text = "" THEN
>     Message.Question("You must enter a number", "OK")
>     GOTO B2_END
>   END IF
>
>   PRINT textbox1.text
>
> B2_END:
>
> END
>
> I know in VB, instead of the GOTO, u place an 'EXIT SUB".
>
> Regards,
>
> Henry
>
>
>
> -------------------------------------------------------
> This SF.Net email is sponsored by: INetU
> Attention Web Developers & Consultants: Become An INetU Hosting Partner.
> Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
> INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user


 Salut

You can use the RETURN keyword !

Return have two act in gambas :
 - simply RETURN to leave the sub
- RETURN $result       to return a function result


Exemple for function :

in vb 

Public Function Weather (Value as Integer) as String

  if Value = 1 then 
    Weather = Sunny
    Exit Function
  End if  

    Weather = Cloudy
End select

End Function


The same in Gambas : 

PUBLIC FUNCTION Weather (Value as Integer) as String

  IF Value = 1 THEN  RETURN Sunny  
  RETURN Cloudy

End select

END

Gambas is great !

Fabien




More information about the User mailing list