O'Reilly logo

Professional Visual Basic 2012 and .NET 4.5 Programming by Todd Herman, Gastón Hillar, David McCarter, Rob Windsor, Billy Hollis, Bill Sheldon

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Translating Values and Behaviors

In the process of globalizing your .NET application, you may notice a number of aspects that are handled differently compared to building an application that is devoid of globalization, including how dates are represented and how currencies are shown. This section looks at some of these issues.

Understanding Differences in Dates

Different cultures specify dates and time very differently. Consider the following date as an example:

08/11/2008

Is this date August 11, 2008, or is it November 8, 2008? It should be the job of the business logic layer or the presentation layer to convert all date and times for use by the end user. To avoid interpretation errors, always use the same culture (or invariant culture) when storing values, such as dates and times, in a database or other data store.

Setting the culture at the server level in ASP.NET or within a Windows Forms application, as shown in the earlier examples, enables your .NET application to make these conversions for you. You can also simply assign a new culture to the thread in which the code is running. Close out the ASP.NET solution you were looking at in the preceding section and return to the ProVB2012_Localization project. Now consider the following code, which can be called from the Button_Click_1 event handler. Note that this Sub is dependent on the Imports statements (code file: MainWindow .xaml.vb):

Imports System.Globalization Imports System.Threading Private Sub DisplayCalendarByCulture() ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required