Click here to Skip to main content
15,880,469 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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 19:39pm

1 solution

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));
        }
    }
}
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900