Results 1 to 6 of 6

Thread: [Resolved] Problem reading languages

  1. #1

    Thread Starter
    Banned
    Join Date
    Jul 2007
    Posts
    400

    Resolved [Resolved] Problem reading languages

    Hi everyone

    I have upgraded to visual basic .NET from using visual basic 6. Some of the codes I have exchanged and when I run on form load, I try to switch to another language but it do not work. Here is the code:



    Form:
    Code:
    Option Explicit On
    Friend Class Form1
    	Inherits System.Windows.Forms.Form
        Private Sub Form_Load()
            IniFile = GetSetting(My.Application.Info.Title, "Common", "IniFile", My.Application.Info.DirectoryPath & "\EN.ini")
            ReadLanguages()
        End Sub
    
        Private Sub LANG_English_Click()
            IniFile = My.Application.Info.DirectoryPath & "\EN.ini"
            ReadLanguages()
            LANG_English.Checked = True
            LANG_French.Checked = False
        End Sub
    
        Private Sub LANG_French_Click()
            IniFile = My.Application.Info.DirectoryPath & "\FR.ini"
            ReadLanguages()
            LANG_English.Checked = False
            LANG_French.Checked = True
        End Sub
    
        Private Sub Form_Unload(ByVal Cancel As Integer)
            SaveSetting(My.Application.Info.Title, "Common", "IniFile", IniFile)
        End Sub
    End Class


    Module1
    Code:
    Option Explicit On
    Module Module1
    	
        Declare Function GetPrivateProfileString Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Object, ByVal lpDefault As String, ByVal lpReturnedString As String, ByVal nSize As Integer, ByVal lpFileName As String) As Integer
    	
        Public Function ReadIniFile(ByVal sIniFileName As String, ByVal sSection As String, ByVal sItem As String, ByVal sDefault As String) As String
            Dim iRetAmount As Short 'the amount of characters returned
            Dim sTemp As String
            'change
            sTemp = New String(Chr(0), 50) 'fill with nulls
            'to
            sTemp = New String(Chr(0), 500) 'fill with nulls
            'change
            iRetAmount = GetPrivateProfileString(sSection, sItem, sDefault, sTemp, 50, sIniFileName)
            'to
            iRetAmount = GetPrivateProfileString(sSection, sItem, sDefault, sTemp, 500, sIniFileName)
            sTemp = Left(sTemp, iRetAmount)
            ReadIniFile = sTemp
        End Function
    End Module


    module2
    Code:
    Option Explicit On
    Module Module2
    	Public Language As String
    	Public IniFile As String
    	
    	Sub CheckMenuItems()
    		With Form1
    			.LANG_English.Checked = False
    			.LANG_French.Checked = False
                Select Case Language
                    Case "English" : .LANG_English.Checked = True
                    Case "French" : .LANG_French.Checked = True
                End Select
    		End With
    	End Sub
    	
    	Sub ReadLanguages()
    		
    		Language = ReadIniFile(IniFile, "Language", "Language", "")
    		Form1.Text = ReadIniFile(IniFile, "Language", "Title", "")
    		CheckMenuItems()
    		
    		Dim ctl1 As System.Windows.Forms.Control
    		For	Each ctl1 In Form1.Controls
    			'UPGRADE_WARNING: TypeOf has a new behavior. Click for more: 'ms-help://MS.VSExpressCC.v80/dv_commoner/local/redirect.htm?keyword="9B7D5ADD-D8FE-4819-A36C-6DEDAF088CC7"'
                If TypeOf ctl1 Is System.Windows.Forms.Control Then
                    ctl1.Text = ReadIniFile(IniFile, "Language", ctl1.Name, "")
                    ctl1.Text = ReadIniFile(IniFile, "Language", ctl1.Name, "")
                End If
    			
    		Next ctl1
    		
    		
    	End Sub
    End Module



    Or the sample one right here.....How can I refix it??



    Thanks,
    Mark
    Last edited by Mark103; Dec 12th, 2007 at 09:02 PM.

  2. #2

    Thread Starter
    Banned
    Join Date
    Jul 2007
    Posts
    400

    Re: Problem reading languages

    anyone??

  3. #3
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: Problem reading languages

    We tell this to just about everyone who comes in asking why old code doesn't work in modern times. Upgrading existing code very rarely works. The best thing to do is to clean rewrite it, using the old code as a base but using the advantages of the new language. You'll get a better app out of it and you'll have learned a good deal about the new.

  4. #4
    PowerPoster VBDT's Avatar
    Join Date
    Sep 2005
    Location
    CA - USA
    Posts
    2,922

    Re: Problem reading languages

    I assume you mean the Input language, so here is an example. This example changes the current input language to Armenian for the application, but you can specify it for any language.
    You just need the language identifier such:

    “hy-AM” – Armenian
    “en-US” – US English
    Etc.

    vb Code:
    1. Dim cInfo As New Globalization.CultureInfo("hy-AM")
    2. InputLanguage.CurrentInputLanguage = InputLanguage.FromCulture(cInfo)

  5. #5

    Thread Starter
    Banned
    Join Date
    Jul 2007
    Posts
    400

    Re: Problem reading languages

    I think it possibly to fix but when I change to another languages it do not work. The title only works, here is the image that you can see what's went wrong, the list of items and menu parts are not exchange from the list of the string valves. I know that the caption are seen to be working but not for the menu parts.



    http://img99.imageshack.us/img99/9975/imagegg5.jpg




    What's wrong, why it don't change??



    Plus, please can you advise me to change the look for the menu size to make it looks like vb6 menu parts??



    Thanks,
    Mark
    Attached Files Attached Files

  6. #6

    Thread Starter
    Banned
    Join Date
    Jul 2007
    Posts
    400

    Re: Problem reading languages

    Please cany someone advise me with this??

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width