I have made two resource files,named

1)Form1.en-US.resx
Name Value
Button1.Text English


2)Form1.fr-FR.resx
Name Value
Button1.Text France

My Code is as Under-

Imports System.Globalization
Imports System.Threading

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ci As CultureInfo
        Dim aL As New ArrayList()
        For Each ci In CultureInfo.GetCultures(CultureTypes.SpecificCultures)
            ComboBox1.Items.Add(ci.Name)
        Next ci
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Dim lang As String
        lang = ComboBox1.SelectedItem

        Thread.CurrentThread.CurrentUICulture = New CultureInfo(lang) 'Changes the Language
    End Sub
End Class

But the Button1 text is not changing.Can Somebody tell where i m wrong?

Recommended Answers

All 5 Replies

I have made two resource files,named Under the folder MyResources & mine project Name Language

1)myres.en-US.resx
Name Value
Button1.Text English


2)myres.fr-FR.resx
Name Value
Button1.Text France

My Code is as Under

Imports System.Globalization
Imports System.Threading
Imports System.Resources
Imports System.IO
Imports System.Reflection

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ci As CultureInfo
        Dim aL As New ArrayList()
        For Each ci In CultureInfo.GetCultures(CultureTypes.SpecificCultures)
            ComboBox1.Items.Add(ci.Name)
        Next ci
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Dim lang As String
        Dim rm As ResourceManager
        lang = ComboBox1.SelectedItem

        ' Thread.CurrentThread.CurrentCulture = New CultureInfo(lang) 'Changes the Language
        Thread.CurrentThread.CurrentUICulture = New CultureInfo(lang) 'Changes the Language

        rm = New ResourceManager("Language.MyLocalResources.myRes", Assembly.GetExecutingAssembly())
        Button1.Text = rm.GetString("Button1.Text")

    End Sub
End Class

But the Button1 text is not changing.Insted Error is there--Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Lnaguage.MyLocalResources.myRes.resources" was correctly embedded .


Can Somebody help me!!!!!!!!!!!

I have made two resource files,named Under the folder MyResources & mine project Name Language

1)myres.en-US.resx
Name Value
Button1.Text English


2)myres.fr-FR.resx
Name Value
Button1.Text France

My Code is as Under

Imports System.Globalization
Imports System.Threading
Imports System.Resources
Imports System.IO
Imports System.Reflection

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ci As CultureInfo
        Dim aL As New ArrayList()
        For Each ci In CultureInfo.GetCultures(CultureTypes.SpecificCultures)
            ComboBox1.Items.Add(ci.Name)
        Next ci
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Dim lang As String
        Dim rm As ResourceManager
        lang = ComboBox1.SelectedItem

        ' Thread.CurrentThread.CurrentCulture = New CultureInfo(lang) 'Changes the Language
        Thread.CurrentThread.CurrentUICulture = New CultureInfo(lang) 'Changes the Language

        rm = New ResourceManager("Language.MyLocalResources.myRes", Assembly.GetExecutingAssembly())
        Button1.Text = rm.GetString("Button1.Text")

    End Sub
End Class

But the Button1 text is not changing.Insted Error is there--Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "Lnaguage.MyLocalResources.myRes.resources" was correctly embedded .


Can Somebody help me!!!!!!!!!!!

hi
actualy u r adding mulilang files into project under resources folder. u need add bin/debug/resources/ here u have to create the textfile.not resouces file

THX I Solved it....SOLUTION--

Imports System.Globalization
Imports System.Threading
Imports System.Resources
Imports System.IO
Imports System.Reflection

Public Class Form1
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim ci As CultureInfo
        Dim aL As New ArrayList()
        For Each ci In CultureInfo.GetCultures(CultureTypes.SpecificCultures)
            ComboBox1.Items.Add(ci.Name)
        Next ci
    End Sub

    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged
        Dim lang As String
        Dim rm As ResourceManager
        lang = ComboBox1.SelectedItem


        'IIND
        Thread.CurrentThread.CurrentUICulture = New CultureInfo(lang)
        rm = New ResourceManager("Lnaguage.Resource", Assembly.GetExecutingAssembly())
        Button1.Text = rm.GetString("Button1")
    End Sub
End Class

Resource File Names-

Resource.en-US.resx
Resource.fr-FR.resx

plz...send me this answer in vb.net 2005 version nd also give me passcode for vb.net 2005 ...plz do it soon..

commented: How about... no. -3
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.