



Imagine that you are developing an application that sends a date (formatted as a string) to a Web service. For example, the Double type provides the ToString(IFormatProvider) and Parse(String, IFormatProvider) methods.įor more information, see Str and Val. Each number object has a ToString(IFormatProvider) method that converts a number to a string, and a Parse(String, IFormatProvider) method that converts a string to a number. The CStr and Format functions convert a number to a string, and the CDbl and CInt functions convert a string to a number.Ĭonversions that use a specific culture. The culturally-aware analogues of these functions are:Ĭonversions that use the current culture. Instead, they recognize only the period (.) as a valid decimal separator. The Str (converts numbers to strings) and Val (converts strings to numbers) functions do not use the application's culture information when converting between strings and numbers. For more information, see Asc, AscW, Chr, ChrW, Format, Hex, Oct, and Type Conversion Functions. Notice that the application's culture settings are, by default, inherited from the culture settings of the operating system. The key to successfully using string-conversion functions in applications that run on computers with different culture settings is to understand which functions use a specific culture setting, and which use the current culture setting. Culture-Sensitive FunctionsĪll of the Visual Basic string-conversion functions (except for the Str and Val functions) use the application's culture information to make sure that the conversions and comparisons are appropriate for the culture of the application's user. However, if the application uploads the date to a central server, it should format the string according to one specific culture, to prevent confusion between potentially different date formats. If your application then presents that date in its user interface, it should present it in the user's culture. Typically, you should use culture-specific strings for all data presented to and read from users, and use culture-invariant strings for your application's internal data.įor example, if your application asks users to enter a date as a string, it should expect users to format the strings according to their culture, and the application should convert the string appropriately. This Help page discusses how Visual Basic uses culture information to perform string conversions and comparisons.
