Click here to Skip to main content
14,420,878 members
Rate this:
Please Sign up or sign in to vote.
HI ,,,

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

<pre>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


Thanks

What I have tried:

convert the program interface to another language interface ??? IN Visual Basic .NET (Visual Studio 2019)
Posted
Updated 29-Nov-19 20:39pm

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Seems ok to me, using an online converter it can be converted to C#.
Convert VB.NET to/from C# online - Roslyn Code Converter[^]
using System;
using System.Globalization;

public partial class Form1
{
    private void ArButton_Click(object sender, EventArgs e)
    {
        Languages.changelanguge("ar");
    }
    private void EnButton_Click(object sender, EventArgs e)
    {
        Languages.changelanguge("en");
    }
}

public static partial class Languages
{
    public static void changelanguge(string languge)
    {
        foreach (Control obj in Form1.Controls)
        {
            var lang = new ComponentResourceManager(typeof(Form1));
            lang.ApplyResources(obj, obj.Name, new CultureInfo(languge));
        }
    }
}
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100