title: keyboard input language changing program
body: <p>I have found some codes written in C# for changing input language programmatically. I adapted the codes for vb.net. But it is not working. Since i am new in programming i cannot find out my fault. Please help me. Thanks in advance.   </p>
  
  <pre><code>Imports System
  Imports System.Collections.Generic
  Imports System.Linq
  Imports System.Text
  Imports System.Windows.Forms
  Imports System.Drawing
  
  Namespace InputLanguagetrial
      Public Class Form1
          Dim _bengaliInput As InputLanguage
          Dim _englishInput As InputLanguage
  
  
          Public Sub New()
              _bengaliInput = GetInputLanguageByName("bengali")
              _englishInput = GetInputLanguageByName("english")
          End Sub
  
          Public Sub SetKeyboardLayout(ByVal layout As InputLanguage)
              InputLanguage.CurrentInputLanguage = layout
          End Sub
  
  
          Public Shared Function GetInputLanguageByName(ByVal inputName As     String) As InputLanguage
              Dim lang As InputLanguage
              For Each lang In InputLanguage.InstalledInputLanguages
                  If   lang.Culture.EnglishName.ToLower().StartsWith(inputName) Then
                      Return lang
                  End If
              Next
              Return Nothing
          End Function
  
          Public Sub LoadBengaliKeyboardLayout()
              If Not _bengaliInput Is Nothing Then
                  InputLanguage.CurrentInputLanguage = _bengaliInput
              Else
                  InputLanguage.CurrentInputLanguage =     InputLanguage.DefaultInputLanguage
              End If
          End Sub
  
          Public Sub LoadEnglishKeyboardLayout()
              If Not _englishInput Is Nothing Then
                InputLanguage.CurrentInputLanguage = _englishInput
              Else
                  InputLanguage.CurrentInputLanguage = InputLanguage.DefaultInputLanguage
              End If
          End Sub
  
          Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
              InputLanguage.CurrentInputLanguage = _bengaliInput
          End Sub
  
          Private Sub TextBox2_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox2.TextChanged
          InputLanguage.CurrentInputLanguage = _englishInput
          End Sub
  
      End Class
  End Namespace
  </code></pre>