CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: need help

  1. #1
    Join Date
    Aug 1999
    Location
    Spain
    Posts
    5

    need help

    Hi,
    does anybody know if the next sentence is correct in a class module:
    Public aVariable1,aVariable2
    and if it is correct, "aVariable2" is also public or not.

    Thanks to all.

    MARC
    ---------



  2. #2
    Join Date
    Apr 1999
    Location
    Netherlands
    Posts
    181

    Re: need help

    *the* way to find out is to try it.. :-)
    But yes, both are Public...

    Crazy D @ Work :-)

  3. #3
    Join Date
    Oct 1999
    Location
    S.W. Wyoming
    Posts
    25

    Re: need help

    As the previous response said, both are public. But I would STONGLY suggest not writing such a line. For instance (and you may have omitted this in haste), in the line you have used as an illustration, both variables are implicitly declared as the default type (since VB 4.0, a Variant) unless you have included a DefInt, DefLng, etc. statement, in which case both variables will take that declared default type, if applicable. This may not result in the data type you wanted. And, are you trying to save linefeeds? I would recommend extra precision:


    public AVariable1 as Integer
    public AVariable2 as Long




    This is not only less subject to such confusion as to whether or not each variable is Public, but the types are not in doubt, and--six months from now, when you look at your own code--you'll be glad you took the time (and the linefeeds) to be precise.


    Reid Allen Robbins
    2205 E. Teton Blvd.
    Green River, WY 82935

  4. #4
    Join Date
    May 1999
    Location
    Omika, Japan
    Posts
    729

    Re: need help

    It actually doesn't take "much time" too :-)
    if Intellesense is 'On', VB will anyway prompt you with "types", as soon as you type the word "as". I can't think, someone will be coding with that setting 'Off'.


    RK

  5. #5
    Join Date
    Aug 1999
    Location
    Spain
    Posts
    5

    Re: need help

    Thanks for your precission,
    I'm developing a Visual Basic compiler and I need to know if these kinds of constructions are correct
    and if they are what happens with the variables scope I know that the example I gave wasn't so precisse
    but I must think about the possibility of have code like that.

    Thank you very much.

    MARC.
    --------


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured