I use the print function to export a Cell Value to csv file. I use this macro on several PCs with different Localization Settings. The problem i am experiencing is, that on some PCs the Output is 4,11 and 4.11 on others. Is there any Format Method, that allows me always write a Number with a semicolon as decimal Seperator?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
As far as I'm aware, there is no format method for changing the decimal separator. Instead your options are temporarily telling Excel to use a special character or using Replace().
Application.UseSystemSeparators = False
Application.DecimalSeparator = ";"
Print #1, rngValue.Text
Or
Print #1, Replace(rngValue, ",", ";")
In either case you then have a problem, when reading the numbers back in, of converting them back to the correct character so they are considered numbers.
A better question might be how do programmers in places that use the comma as the decimal separator handle decimal values in CSV files?