Format strings in VBA are slightly different than format strings in .NET.
For example, yyyy-mm-dd hh:mm:ss
is a valid VBA format string that renders as 2020-07-29 14:56:23
, where as the corresponding .NET format string would look like yyyy-MM-dd hh:mm:ss
. The ambiguity of mm
in VBA's case is resolved because the mm
returns minutes only when preceded by h
or hh
.
I'm writing a C#/.NET service that is reading from some legacy system which stores format strings in the VBA format, and now I need to convert these format strings to .NET which is what my downstream applications expect. Is there some standard way to convert a format string from VBA to .NET?
I can write my own converter if needed, but if something already exists out there, I'd really like to avoid reinventing the wheel.
To clarify: I am not looking for a way to format a string using a VBA format string in .NET. This can easily be done by referencing Microsoft.VisualBasic.Compatibility
or using P/Invoke.
I am looking for a way to convert a format string from the VBA format string format, to the .NET format string format, to pass it along to code that I don't control.