Search code examples
vb.netvisual-studiointerfacemultilingualglobalization

Convert the program interface to another language interface VB.NET


What is wrong with the code to convert the program interface to another language interface? In Visual Basic .NET (Visual Studio 2019)

Imports System.Globalization
Imports System.ComponentModel

Public Class Form1
    Private Sub ArButton_Click(sender As Object, e As EventArgs) Handles ArButton.Click
        Languages.changelanguge("ar")
    End Sub
    Private Sub EnButton_Click(sender As Object, e As EventArgs) Handles EnButton.Click
        Languages.changelanguge("en")
    End Sub
End Class

Public Module Languages
    Public Sub changelanguge(ByVal languge As String)
        For Each obj As Control In Form1.Controls
            Dim lang As ComponentResourceManager = New ComponentResourceManager(GetType(Form1))
            lang.ApplyResources(obj, obj.Name, New CultureInfo(languge))
        Next
    End Sub
End Module

Solution

  • What is happening when you run the code? I was implementing this recently and the below link assisted a lot.

    https://learn.microsoft.com/en-us/dotnet/api/system.globalization.cultureinfo?view=netframework-4.8