Hey Johnny,

honestly, a lot of your questions/things are "basics"...

VALUE, STRING, FORMULA and DATETIME are reserved words in Basic and
cannot be used as constant or variable names. Ever thought about this?

Try to put a character in Front (i.E. nValue, or myString)  and
everything works as expected....

Best regards
Thomas


Am 18.08.2011 12:52, schrieb Johnny Rosenberg:
> Here's another delicate problem that's easy to work around, but still
> very strange:
> 
> Module 2:
> ———Code starts below———
> REM  *****  BASIC  *****
> 
> Option Explicit
> 
> Public Const VALUE=1
> Public Const STRING=4
> Public Const FORMULA=16
> Public Const DATETIME=2
> 
> Sub HelloWorld
>       Print "Hello world!"
> End Sub
> ———End of code———
> 
> 
> Module1:
> ———Code starts below———
> REM  *****  BASIC  *****
> 
> Option Explicit
> 
> Sub Main
>       Dim A
>       A=VALUE+STRING+FORMULA
> End Sub
> ———End of code———
> Run Main and you will get an error message at ”A=VALUE+STRING+FORMULA”.
> If you run step by step (Ctrl+F8 in the BASIC IDE) and stop at that
> line and then hover your mouse pointer over VALUE or STRING or
> FORMULA, you can clearly see its values, but obviously this doesn't
> help. Dimensioning A as Variant, as I did, doesn't help either. If you
> look at VALUE, STRING or FORMULA in the variable monitor (or whatever
> it's called in English), the window at the bottom left, you can see
> that they are Variant/Integer and you can see their correct values.
> 
> So now, let's move the constant definition to Module1:
> Module 2:
> ———Code starts below———
> REM  *****  BASIC  *****
> 
> Option Explicit
> 
> Sub HelloWorld
>       Print "Hello world!"
> End Sub
> ———End of code———
> 
> 
> Module1:
> ———Code starts below———
> REM  *****  BASIC  *****
> 
> Option Explicit
> 
> Public Const VALUE=1
> Public Const STRING=4
> Public Const FORMULA=16
> Public Const DATETIME=2
> 
> Sub Main
>       Dim A
>       A=VALUE+STRING+FORMULA
> End Sub
> ———End of code———
> 
> Now Main in Module1 works as expected, but take a look in the monitor
> again. Those constants appears in exactly the same way this time as
> before, the only exception is that this works.
> I would be very grateful for an explanation about this. Is there
> REALLY a logical reason for it to be this way or should I report this
> as a bug as soon as possible?
> 
> Of course I can define those constants in every module, but isn't one
> of the points by declaring as Public that I can reach them in all my
> modules? Well, in this case I can; I just can't use them, at least not
> when adding them to each other.
> ”A=VALUE” works in both my examples, but obviously not
> ”A=VALUE+STRING+FORMULA” for some reason I am sure absolutely nobody
> can explain, so please prove me wrong here…!
> 
> :D
> 
> 
> Kind regards
> 
> Johnny Rosenberg
> ジョニー・ローゼンバーグ

-- 
-----------------------------------------------------------------
To unsubscribe send email to dev-unsubscr...@api.openoffice.org
For additional commands send email to sy...@api.openoffice.org
with Subject: help

Reply via email to