ApplicationBase.ChangeUICulture Method (String)

 

Changes the culture that the current thread uses for retrieving culture-specific resources.

Namespace:   Microsoft.VisualBasic.ApplicationServices
Assembly:  Microsoft.VisualBasic (in Microsoft.VisualBasic.dll)

public void ChangeUICulture(
	string cultureName
)

Parameters

cultureName
Type: System.String

String. Name of the culture as a string. For a list of possible names, see CultureInfo.

Exception Condition
ArgumentNullException

cultureName is Nothing.

ArgumentException

cultureName is not a valid culture name.

The My.Application.ChangeUICulture method changes the current thread's CurrentUICulture property. The CurrentUICulture property determines the culture used by the Resource Manager and the My.Resources object; it uses this information to look up culture-specific resources at run time.

To retrieve the current UI culture, you can use the UICulture property or the CurrentUICulture property.

Use the My.Application.ChangeCulture method to change the culture that the current thread uses for string manipulation and string formatting.

Project type

Available

Windows Forms Application

Yes

Class Library

Yes

Console Application

Yes

Windows Forms Control Library

Yes

Web Control Library

No

Windows Service

Yes

Web Site

No

This example uses the My.Application.ChangeUICulture method to set the culture that the My.Resources object uses for retrieving resources.

Sub ShowLocalizedMessage()
    Dim culture As String = My.Application.UICulture.Name
    My.Application.ChangeUICulture("fr-FR")
    MsgBox(My.Resources.Message)
    My.Application.ChangeUICulture(culture)
End Sub

For this example to work, your application must have a string named Message in the application's resource file, and the application should have the French-culture version of that resource file, Resources.fr-FR.resx. For more information, see How to: Add or Remove Resources.

If the application does not have the French-culture version of that resource file, the My.Resources object retrieves the resource from the default-culture resource file.

.NET Framework
Available since 2.0
Return to top
Show: