My.Application.Culture Property 

Gets the culture that the current thread uses for string manipulation and string formatting.

' Usage
Dim value As System.Globalization.CultureInfo = My.Application.Culture
' Declaration
Public ReadOnly Property Culture As System.Globalization.CultureInfo

Return Value

Returns a CultureInfo object that represents the culture the current thread uses for string manipulation and string formatting.

Remarks

The My.Application.CurrentCulture property gets the CultureInfo object that the current thread uses for string manipulation and string formatting. This object is identical to the one returned by the CurrentCulture property, which controls many of the string-related computations on that thread. The CurrentCulture property determines the default formats for dates, times, currency, and numbers. It also determines how to sort, compare, and capitalize strings.

To change the culture, you can use the My.Application.ChangeCulture Method or assign a different CultureInfo object to the CurrentCulture property.

The CurrentCulture setting is different from a language setting. It contains only data related to the standard settings for a geographical region.

Use the My.Application.CurrentUICulture property to get the culture that the current thread uses for retrieving culture-specific resources.

Example

This example demonstrates how the culture affects the string representation of dates.

Private Sub TestChangeCulture()
    ' Store the current culture.
    Dim currentculture As String = My.Application.Culture.Name
    MsgBox("Current culture is " & currentculture)

    Dim jan1 As New Date(2005, 1, 1, 15, 15, 15)

    My.Application.ChangeCulture("en-US")
    MsgBox("Date represented in en-US culture: " & jan1)
    ' 1/1/2005 3:15:15 PM

    My.Application.ChangeCulture("")
    MsgBox("Date represented in invariant culture" & jan1)
    ' 01/01/2005 15:15:15

    ' Restore the culture.
    My.Application.ChangeCulture(currentculture)
End Sub

Requirements

Namespace: Microsoft.VisualBasic.ApplicationServices

Class: WindowsFormsApplicationBase, ApplicationBase

Assembly: Visual Basic Runtime Library (in Microsoft.VisualBasic.dll)

Availability by Project Type

Project type Available

Windows Application

Yes

Class Library

Yes

Console Application

Yes

Windows Control Library

Yes

Web Control Library

No

Windows Service

Yes

Web Site

No

Permissions

No permissions are required.

See Also

Reference

My.Application Object
My.Application.ChangeCulture Method
My.Application.UICulture Property
System.Globalization.CultureInfo
CurrentCulture
Microsoft.VisualBasic.ApplicationServices.ApplicationBase.Culture