[Gambas-user] File opening dialog and one more question

Willy Raets willy at ...2734...
Fri Jan 6 16:40:28 CET 2012


On vr, 2012-01-06 at 07:33 -0800, Dmitrij Malkov wrote:

> I wondered that the code
> -------------------------------------------
> Public Sub Main()
>    CUnit.HowManyUnits()
> End
> -------------------------------------------
> works, but the code
> -------------------------------------------
> Public Sub Main()
>    CUnit.HowManyUnits()
>    Dim Unit1 As New CUnit 
> End
> -------------------------------------------
> does not ("Dim is unexpected"). I awaited a message like "CUnit is not an
> object" in a worst time. You answered, that gambas syntax doesn't allow it.
> But in the documentation the next only is written: "All DIM declarations
> must be in the FUNCTION or SUB before the first executable command." I don't
> see that I have breaked this.


Well you have broken that.
Afther Public Sub or Function Dim comes first.
In your code Dim comes second

Try:

Public Sub Main()
     Dim Unit1 As New CUnit 
     CUnit.HowManyUnits()
End

Willy





More information about the User mailing list