Results 1 to 6 of 6

Thread: [Resolved] Problem reading languages

Threaded View

  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.

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