dcsimg
Results 1 to 20 of 20

Thread: [RESOLVED] Case Sensitivity Issue

  1. #1

    Thread Starter
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,406

    Resolved [RESOLVED] Case Sensitivity Issue

    In a project, I declare, for example, a variable "x" (lower case) as Integer SEVERAL times, locally. Some (or one) may have been at one time declared as a capital ("X"). I noticed it in one particular form in my project that even though I created a new local variable, lower case "x", after I run the program, quit the program, and restart it, it, and all lower cased x's, are changed to "X" (capital).


    Before I run the program (all in IDE right now), I save it. Then, after I run the program, and decide to quit it, I am prompted to save or not? (Don't know why as I saved it (the form on which I was working) before running it).) So, I select "SAVE" and then restart the program...at that point ALL my 'x' variables are capitalized.


    Googling says I can do this:


    Option Compare Text


    But I really don't want to, as I may want a capital X somewhere, and a lowercase x elsewhere (Doubt I will as that is not my practice...I USUALLY use lower case x).


    Can anyone explain why this occurs?


    (If I went through my program (several forms---about 15 or so, and a few modules (NONE of which have a declaration of an x or an X), if I changed ALL of those declaration to lower case, would THAT solve the issue...and if so, WHY?)

  2. #2
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,005

    Re: Case Sensitivity Issue

    Option Compare Text does not affect variable names. It affects text comparison: = <> > <

    Though this is annoying, it doesn't harm your project with VB forcing upper or lower case on variable names, since those are case-insensitive within the project itself.

    If you want to fix it, you can do this. In the declarations section, add:
    Code:
    #If False Then
        Dim X  ' notice that we don't include vartype
    #End If
    For more information, look at this thread: http://www.vbforums.com/showthread.p...-Case-of-Enums
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  3. #3

    Thread Starter
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,406

    Re: Case Sensitivity Issue

    Interesting (the Compare Text thing was what someone on this Forum had recommended a few years ago!, but I never attempted it...sounded strange). This is the first project I have EVER noticed it on. Is it because I may have declared it capitalized once (or more)?

    I know it doesn't hurt, but it IS annoying (at least to me)...I did change one declaration to "x1", and that did not change, but my x's and y's in the one project all get capitalized.

    As far as that link, I see how Bonnie 'fixed it' (as you did here), but I do not use ENUM in my project.

    In my project, I DO have a lower case variable 'z' declared a few times (and never did I declare it capitalized), and it STAYS lowercase.

    Confusing...x's and y's but not z's. ~smile~

  4. #4
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,005

    Re: Case Sensitivity Issue

    How it happens? Don't know the details. One time I was so annoyed with it that I closed the project, changed every instance of the variable by opening all project files in NotePad and doing a Search & Replace. Did that work? Hell no!

    In some cases, I think that an included reference may be triggering it. In any case, whether Enums are used or not, I think that workaround still applies. Did it in your case?
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  5. #5

    Thread Starter
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,406

    Re: Case Sensitivity Issue

    Nope....Now, to caveat, I put it in a Module and said Public. No affect.

    Are you suggesting this go in every one of my many forms? I have not tried it in ANY forms yet...maybe I'll put it in my Main form (the one that runs first) and see if that works.

    (If i want all lowercase, should that code you posted by a lower or upper case X?)

  6. #6
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,005

    Re: Case Sensitivity Issue

    Between the #If and #End If statements, enter the variable the way you want it displayed.

    Also, when you said you replaced the variable with the proper case throughout your project, did you remember to check all TYPE and ENUM statements, all API declaration parameters, all event/method parameters? I typically try to do a project-wide Search & Replace, ensuring the "Find Whole Word Only" and "Match Case" find options are checked. Save the project after changes are made and before it is run again. That doesn't always work though which is even more annoying.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  7. #7

    Thread Starter
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,406

    Re: Case Sensitivity Issue

    I have NOT done a Global Search and Replace. That's my next step...(where does that code go....module (public)? One form (Dim) or EACH form (Dim)?
    I'll report back on the GS&R.

  8. #8

    Thread Starter
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,406

    Re: Case Sensitivity Issue

    Interesting....I did a GS&R, but it said it only found 25 instances of upper case X (I know there are lot more).
    Shut down, restarted, Upper case X's again.
    So, did another GS&R (see image)...it did not find ANY upper case X's in the whole project, yet I SEE some right there (in the image).

    EDIT...the first time I did the entire project, this time (shown in the picture, only this form).

  9. #9

    Thread Starter
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,406

    Re: Case Sensitivity Issue

    Oh well...got a bunch of things to do...will come back to this annoyance later.

  10. #10

    Thread Starter
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,406

    Re: Case Sensitivity Issue

    Quote Originally Posted by LaVolpe View Post
    You didn't search the entire project, only the current module according to your screenshot
    See my edit

    Here it is done AGAIN....

  11. #11
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,005

    Re: Case Sensitivity Issue

    And difficult for us to play along. Gotta be able to break it bad enough where simply re-typing the variable in the correct case doesn't work. If we can't break it on demand, can only offer up trial & error ideas
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  12. #12

    Thread Starter
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,406

    Re: Case Sensitivity Issue

    Gotta run...will check back later...

  13. #13

    Thread Starter
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,406

    Re: Case Sensitivity Issue

    Sorry....
    It's confusing to y'all...AND ME!

    I'll keep trying...maybe I'll change all "X"'s to iX. We'll see.

  14. #14

    Thread Starter
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,406

    Re: Case Sensitivity Issue

    This is simply just Crazy!

    First, I put

    Code:
    #If False Then    
        Public x  ' notice that we don't include vartype
    #End If
    in a MODULE (note the lower case x)

    In a form, I changed AN instance of Dim X As Integer, to Dim x As Integer. Ran the program, exited (was prompted to save the form, I did (even though I saved it right after changing the upper case X to lower case. When I returned to the project, the Dim x As Integer (which I typed) was changed to Dim X As Integer.

    Then, I went to the Module, AND THAT X WAS ALSO UPPER CASE! So I changed it (see code above) to a lower case x. Then I copy-pasted those three lines to the form in which I was using, and after it pasted, THE X WAS UPPER CASE!!!!!

    So, I changed it...put that same code in the form (but changed Public to Dim)...made the x in that three line code lower case, made the Dim x As Integer with a lower case x. Ran it. Exited. Restarted project, and ALL X's ONCE AGAIN WERE UPPER CASE.

    Guess I just need to forget this whole thing and not to be concerned on the case of the variable.

    VERY CONFUSING.

  15. #15

    Thread Starter
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,406

    Re: Case Sensitivity Issue

    Found this:

    It [VB6 IDE]will change the case of all variables with the same name in your entire project. So even if they're declared in uppercase in one place, another module might have different variables using the same variable names in lowercase, causing all variables in your project to change to lowercase, depending on which of the declarations was loaded (?) or edited last.
    How would I find out which as loaded/edited last? Even then, I'm not sure that is the answer...

  16. #16
    VB-aholic & Lovin' It LaVolpe's Avatar
    Join Date
    Oct 2007
    Location
    Beside Waldo
    Posts
    19,005

    Re: Case Sensitivity Issue

    How about this: Change ALL variables X to be renamed xyz. Then close VB and save the project. Load the project again, and run it to ensure no errors. Now change all xyz back to x. Does that work?

    Regarding your question. The date/time on the project file might help, but that only tells you which file was last updated, not necessarily what in that file. Maybe it has to do with the order in which the files get loaded? Is there any way to know for sure?

    That is why I tried to do a Search & Replace within NotePad on all the project files, but that failed for me too. However, that might have been a slightly different case than yours -- I honestly don't recall all the details.

    Edited: X, Y might be a bit problematic anyway. Those variables are also declared quite often in the base VB6 TLBs used within your project. Those may be the reason why you can't keep them lower case? And even if the do stay lower case, will a change later revert them back?
    Last edited by LaVolpe; Nov 16th, 2019 at 04:45 PM.
    Insomnia is just a byproduct of, "It can't be done"

    Classics Enthusiast? Here's my 1969 Mustang Mach I Fastback. Her sister '67 Coupe has been adopted

    Newbie? Novice? Bored? Spend a few minutes browsing the FAQ section of the forum.
    Read the HitchHiker's Guide to Getting Help on the Forums.
    Here is the list of TAGs you can use to format your posts
    Here are VB6 Help Files online


    {Alpha Image Control} {Memory Leak FAQ} {Unicode Open/Save Dialog} {Resource Image Viewer/Extractor}
    {VB and DPI Tutorial} {Manifest Creator} {UserControl Button Template} {stdPicture Render Usage}

  17. #17
    PowerPoster
    Join Date
    Feb 2012
    Location
    West Virginia
    Posts
    13,152

    Re: Case Sensitivity Issue

    I don't think I have ever noticed this behavior. I also use x a lot, pretty much my go to in a for loop. Now of course I never have x defined as public or at form,class or module level, always local I pretty much always use lower case though there have been times where I have used X, maybe it changed somewhere and I did not notice it and if so then no biggie.

    If you saved the project when you ran it and made no changes during debugging then it should not prompt you to save on exit. The only thing that I could see there is that somehow during the debugging those xs were changed to Xs and that told VB it had unsaved changes. I do not recall ever having saw that happen in the years I have been using it. I do have it set to prompt for saving every time I hit the run button and generally do save it at that point unless it is just a quick little project that I have no intention of keeping.

  18. #18
    PowerPoster
    Join Date
    Feb 2017
    Posts
    2,215

    Re: Case Sensitivity Issue

    The X and Y are capitalized because there are some Mouse events procedures used (MouseMove... MouseDown).

    Code:
    Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    From that declaration, VB changes all the other x and y's.

  19. #19

    Thread Starter
    PowerPoster SamOscarBrown's Avatar
    Join Date
    Aug 2012
    Location
    NC, USA
    Posts
    7,406

    Re: Case Sensitivity Issue

    @Eduardo....As I had changed all X's to x's, I have NO ucase X's in mouse events any more....still had same issue however in dimming.

    @Lavolpe...I changed ALL X's to intX, and then ALL x's to intX (there were over 1400 total)...Interesting, as I thought I had changed ALL ucase to lcase (but then, when restarting before changing to intX), many were changed to ucase.). I then closed the project, reopened it, and all intX's were as should be. I then changed all intX's to lower case x. (Saved it, of course). Ran the project. Closed it (was again, for some unknown reason, prompted to save it (it being the only form I opened to check the x's). First time I said no, don't save. Opened the project, all x's were lower case. So I ran it again, closed it (again prompted, this time said yes)...opened it back up, and all x's still lower case.

    This is the only project of the many hundreds I've built that I have noticed this anomaly. I THINK the global change of ALL x's (both ucase and lcase) to another variable name (like intX) and then changing them all back to lower case x WORKED!

    As of now, all is right with this project (well, the x issue, that is), so am going to mark as Resolved. Maybe others will experience this sometime and happen onto this thread and also take LaVolpe's advice. (Googling yesterday showed that several people have seen this issue in the past as well---but first time I saw global changes to another variable name, and then back to original (staying away from simply trying to chance ucase to lcase).

    @DataMiser...yeah, I never declare x's and y's and such globally...just in this one case I tried that three line code in a module, making it public), but eventually took that out.

    Thanks to all for input...

  20. #20
    PowerPoster
    Join Date
    Feb 2017
    Posts
    2,215

    Re: Case Sensitivity Issue

    Quote Originally Posted by SamOscarBrown View Post
    several people have seen this issue in the past as well
    I saw it. My decission was that all X and Y will be always uppercase.

    Edit: my reason is because even when you manage to get all the x and y lowercase, as soon as you add a new mouse event they will get all uppercase again.

    And since the case of the x and y are not too important to me, I prefer not to have do do a whole search and replace every time I add a mouse event.

    Test project attached. The x and y are lowercase, but double click on the form and select MouseMove. All uppercase again!
    Attached Files Attached Files
    Last edited by Eduardo-; Nov 17th, 2019 at 12:29 PM.

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width