skip to Main Content

My co-worker and I were debugging an issue when we came across something curious: the same bit of VB code produces a different output on my machine versus his. We cannot figure out why.

The code:

Dim textForMatching = unmatchedRecord.MetaDataString + " - " + unmatchedEvent.StartDate?.ToLocalTime().Date

On my machine, the output would be something like 10d775fff794 - 06/15/2023 while on his machine the output is 10d775fff794 - 6/15/2023. That leading 0 in my date output is missing from his.

We’re in the same time-zone and we’re both using the same version of Visual Studio.

Does anyone know why this happens? It is some localization interplay due to the implicit conversion to a string by using the + operator? Or are there settings on our computers which could be slightly different and lead to this?

2

Answers


  1. Check your registry: HKEY_CURRENT_USERControl PanelInternational the sShortDate setting. Is it different on each machine?

    I believe this is how it determines the date format to use.

    Login or Signup to reply.
  2. You should study the documentation.

    Then you’ll find:

    Note that the exact output depends on the current culture and the
    local time zone of the system on which it is run.

    So, the reason is that you are using different Windows settings for date and time.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search