Results 1 to 5 of 5

Thread: A Capital Question of Style

  1. #1

    Thread Starter
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109

    A Capital Question of Style

    I was just looking at some of the style notes in VS2019 and found something odd enough I thought I'd ask folks about it.

    I name any class level variables with the prefix 'm', which is lower . This only serves to differentiate form level versus local variables for me, but it is a habit I have long held. 'm' stands for "marsupial", of course.

    VS style notes have no problem with this naming convention...most of the time. However, if I declare a variabe WithEvents, then they DO have a problem with it. Therefore:
    Code:
    Private mErrors As Something 'This is fine.
    Private WithEvents mErrors As Something 'This is not fine
    What the style notes say is "These words must begin with upper case characters: mErrors"

    That seems really wrong to me. It's still a variable. It will be used like any other member variable with the exception of the fact that it might (should) appear in a Handles clause.

    What is the reasoning behind that style note?
    My usual boring signature: Nothing

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Posts
    12,398

    Re: A Capital Question of Style

    When a variable is defined using WithEvents, it becomes a non-field member.

    By default ( Tools > Options > Text Editor > Basic > Code Style > Naming), non-field members require pascal case and will give you a suggestion to fix it when it isn't.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | HtmlLessons | CssLessons | Code Tags | Sword of Fury - Jameram

  3. #3
    PowerPoster
    Join Date
    Nov 2017
    Posts
    3,632

    Re: A Capital Question of Style

    Just another example of Capitalism run amok. Thanks [current or recent US President that you vehemently disagree with]!

  4. #4

    Thread Starter
    Super Moderator Shaggy Hiker's Avatar
    Join Date
    Aug 2002
    Location
    Idaho
    Posts
    40,109

    Re: A Capital Question of Style

    Quote Originally Posted by OptionBase1 View Post
    Just another example of Capitalism run amok. Thanks [current or recent US President that you vehemently disagree with]!


    That's an awesome answer.
    My usual boring signature: Nothing

  5. #5
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,897

    Re: A Capital Question of Style

    Quote Originally Posted by OptionBase1 View Post
    Just another example of Capitalism run amok. Thanks [current or recent US President that you vehemently disagree with]!
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

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