Annoying vba behavior

I am using Access 2007, and this behavior can be replicated as follows.

1) Create a new accdb access database file.
2) Open the database and create a new vba module.
3) Create the 1st subroutine sub1:

Sub sub1() Msgbox Err.Description End Sub 

4) Create a second sub2 routine:

 Sub sub2(Description as String) Msgbox Description End Sub 

At this point, everything is fine.
5) But if I go and change sub2 so that "Description" reads "description", i.e. Changed "D" to "d" like this:

 Sub sub2(Description as String) Msgbox Description End Sub 

It also has the effect of tapping and changing sub1 too! So sub1 now reads:

 Sub sub1() Msgbox Err.Description End Sub 

Why is Err.Description changed to Err.description?

This behavior does not seem to affect the actual functionality of the code, so there is no problem. The big problem is that I export my vba modules as text files and put them under SVN control. And most recently, because of this, a whole load of meaningless "changes" was recorded in the repository.

Any ideas on how to stop this?

+6
source share
2 answers

Unfortunately. This is a tough "feature" of VBA. See a similar question here: How to restore the default case for a variable in VBA (Excel 2010)?

The way I worked with the source code is to run my repository through a script that does the following:

  • Discard all modified files using vba code extensions (creating .orig backup files)
  • Make case insensitive .orig file comparisons with your peers
  • If there are no changes (outside the changes in the case), delete the .orig file
  • For other .orig files (those that have actual changes), delete the partner file and remove the .orig extension

What this does is to hide the files in which the only changes are relevant (a constant problem when working with VBA files, how are you worried). It does not hide changes in the file in which other changes were made. This is far from an ideal solution, but it is the best that I came up with.

+5
source

Also, remember that in VBA, variable names are not case sensitive. Thus, the description and description are the same within the same field.

0
source

Source: https://habr.com/ru/post/887211/


All Articles