Results 1 to 9 of 9

Thread: Capitalisation (or capitalization)

  1. #1

    Thread Starter
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536

    Capitalisation (or capitalization)

    I'm working on a large application made up of a number of different projects all loaded in the IDE at the same time.

    Quite often VB's context-sensitive auto-complete feature changes the capitalisation of variables/method names. Has anyone had this experience and, more importantly does anyone know how to fix it?

    What I'm talking about is if you have a method called "ID" in a class sometimes VB will change it to "Id" where you use it (e.g. MyObject.Id) and every time you try to correct the capitalisation it won't let you.

    We use VSS to store our source code. When the code comes out of VSS it has correct capitalisation (I checked it using Notepad). However, when it's loaded into VB's IDE it goes screwy.

    Hope this makes sense? I've spent all morning trying to sort it out. Any help would be appreciated.

    I'm wondering if the VB attributes in the .frm files (e.g. "Attribute VB_PredeclaredId = False") have anything to do with it?
    This world is not my home. I'm just passing through.

  2. #2
    Addicted Member JensPeder's Avatar
    Join Date
    Sep 2005
    Posts
    249

    Re: Capitalisation (or capitalization)

    Woulden't a "Option Explicit" take care of it? Or am I way of track? But as to WAY it happens, I sadly don't have an answer

  3. #3

    Thread Starter
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536

    Re: Capitalisation (or capitalization)

    Woulden't a "Option Explicit" take care of it?
    Sadly, no.

    Option Explicit forces you to declare your variables (which is a very good thing. My problem is that VB is automatically changing the case of my variable and method names.

    If you declare a public variable "MyVariable As Long" in your form then you can type myvarIABLE elsewhere in your code and VB automatically corrects it to "MyVariable". What I'm getting is that VB is chaning the capitalisation incorrectly - even though I have declared the variable as required and even type it correctly VB still changes it to the wrong case.
    This world is not my home. I'm just passing through.

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: Capitalisation (or capitalization)

    Quote Originally Posted by trisuglow
    If you declare a public variable "MyVariable As Long" in your form then you can type myvarIABLE elsewhere in your code and VB automatically corrects it to "MyVariable".
    This I have had happen, and in fact, I count on it. When I type out a variable, I always type it out in all lower case and wait to see if VB will correct it for me. If it does, then I know I typed the variable name correctly.
    Quote Originally Posted by trisuglow
    What I'm getting is that VB is chaning the capitalisation incorrectly - even though I have declared the variable as required and even type it correctly VB still changes it to the wrong case.
    This I have never had happen, or seen happen.

  5. #5
    Addicted Member JensPeder's Avatar
    Join Date
    Sep 2005
    Posts
    249

    Re: Capitalisation (or capitalization)

    Quote Originally Posted by trisuglow
    Sadly, no.

    Option Explicit forces you to declare your variables (which is a very good thing. My problem is that VB is automatically changing the case of my variable and method names.

    If you declare a public variable "MyVariable As Long" in your form then you can type myvarIABLE elsewhere in your code and VB automatically corrects it to "MyVariable". What I'm getting is that VB is chaning the capitalisation incorrectly - even though I have declared the variable as required and even type it correctly VB still changes it to the wrong case.
    My bad! Still, strange stuff

  6. #6
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Capitalisation (or capitalization)

    I've experienced this many times. But I just ignore it as it doesn't make any difference. VB is case-insensitive.

    Pradeep
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  7. #7

    Thread Starter
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536

    Re: Capitalisation (or capitalization)

    I've experienced this many times. But I just ignore it as it doesn't make any difference. VB is case-insensitive.
    You're right, but we want to keep our code tidy and make it easy to read. Do you have any ideas at all that might help?
    This world is not my home. I'm just passing through.

  8. #8
    VB Addict Pradeep1210's Avatar
    Join Date
    Apr 2004
    Location
    Inside the CPU...
    Posts
    6,614

    Re: Capitalisation (or capitalization)

    Quote Originally Posted by trisuglow
    You're right, but we want to keep our code tidy and make it easy to read. Do you have any ideas at all that might help?
    What I have observed is that if you have a variable name with the same name as the property/method (just cases different) it misbehaves.
    So whenever I correct the case of the variable name, it starts working properly.

    Try this:
    At form level type Dim ID
    Observe that the property/method ID has been capitalized correctly.
    Now delete the line you added and save the project.


    Pradeep
    Pradeep, Microsoft MVP (Visual Basic)
    Please appreciate posts that have helped you by clicking icon on the left of the post.
    "A problem well stated is a problem half solved." — Charles F. Kettering

    Read articles on My Blog101 LINQ SamplesJSON ValidatorXML Schema Validator"How Do I" videos on MSDNVB.NET and C# ComparisonGood Coding PracticesVBForums Reputation SaverString EnumSuper Simple Tetris Game


    (2010-2013)
    NB: I do not answer coding questions via PM. If you want my help, then make a post and PM me it's link. If I can help, trust me I will...

  9. #9

    Thread Starter
    Frenzied Member trisuglow's Avatar
    Join Date
    Jan 2002
    Location
    Horsham, Sussex, UK
    Posts
    1,536

    Re: Capitalisation (or capitalization)

    Pradeep, I've tried this and it looks like it could be a top tip. I'll see what happens and report back...
    This world is not my home. I'm just passing through.

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