Bug or feature ? 
Author Message
 Bug or feature ?

Hello,

I have a BAS module which contains global procedures and constants. I have
a procedure called AlignIt. For readability, I had declared it's constants
just above this procedure. So the code looked like this

        Global Const SomeConst = 1
         ....
        Public Function SomeOtherProcedure()
        ....
        End Function

        Global Const SP_CENTER = 0
        Public Function AlignIt( pnAlignment as long, psText as String, pnLength
as long) As String
        ...
        End Function

While compiling VB5 complained in another module that SP_CENTER is not
declared. I checked the global BAS module to make sure it had been declared
GLOBAL. It was indeed declared as global. So it should have been available
to other modules.

Then I moved these constants to the top of the module. That is, before all
the procedures.
        Global Const SomeConst = 1
        Global Const SP_CENTER = 0
         ....
        Public Function SomeOtherProcedure()
        ....
        End Function

        Public Function AlignIt( pnAlignment as long, psText as String, pnLength
as long) As String
        ...
        End Function

Now this constant is visible to all the modules.

Seems like if you declare a global constant BETWEEN the PROCEDURES, it is
not visible outside. IF you declare it BEFORE ALL the PROCEDURES, it is
visible.

Is this a feature of VB or a bug ? If it is a feature, then what is the
purpose of such a feature ?

Rahul
--
Remove the word REMOVEME from my email id
before sending mail. It is there to confuse robo
spammers.



Tue, 09 Nov 1999 03:00:00 GMT  
 Bug or feature ?

->
->Hello,
->
->I have a BAS module which contains global procedures and constants.
I have
->a procedure called AlignIt. For readability, I had declared it's
constants
->just above this procedure. So the code looked like this
->
->   Global Const SomeConst = 1
->    ....
->   Public Function SomeOtherProcedure()
->   ....
->   End Function
->
->   Global Const SP_CENTER = 0
->   Public Function AlignIt( pnAlignment as long, psText as

The reference has to be in the General Declarations in order for it to
be defined as Public or Global. Otherwise its scope is restricted to
the module level.

Paul
~~~~



Tue, 09 Nov 1999 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. DoCmd.Close (Bug or Feature?)

2. bug or feature with expression columns

3. CType(), Bug or Feature??

4. Bug or Feature?

5. Windows bug or feature?

6. Free online bug report / feature enhancement tracking

7. VB5 SP3 bug or feature?

8. RichTextBox BUG or feature?

9. Add-in problem -- bug or feature?

10. HE: DataGrid BUG OR FEATURE

11. Masked Edit Control (Bug or Feature)

12. Bug or Feature with ADO Command Object?

 

 
Powered by phpBB® Forum Software