Results 1 to 3 of 3

Thread: INI-files for different languages

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2000
    Location
    Beverwijk, Holland
    Posts
    14

    Exclamation

    Hi,

    I'm creating a program for resistor values and I want the users be able to create/edit an INI-file for their language, but I can't find source code to use this on my form. I'm thinking about the Tag-property, but does anyone have good code, I can use?

    Thnx
    Live Long and Prosper,

    Leo Schelvis
    [ECH]

    VB6

  2. #2
    Guest
    To read/write an INI file:

    Code:
    Public Declare Function GetPrivateProfileString _
    Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal _
    lpApplicationName As String, ByVal lpKeyName As String, _
    ByVal lpDefault As String, ByVal lpReturnedString As _
    String, ByVal nSize As Long, ByVal lpFileName As String) As _
    Long
    
    Public Declare Function WritePrivateProfileString _
    Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal _
    lpApplicationName As String, ByVal lpKeyName As Any, ByVal _
    lpString As Any, ByVal lpFileName As String) As Long
    
    
    Public Function ReadINI(strsection As String, strkey As String, strfullpath As String) As String
       Dim strbuffer As String
       Let strbuffer$ = String$(750, Chr$(0&))
       Let ReadINI$ = Left$(strbuffer$, GetPrivateProfileString(strsection$, ByVal LCase$(strkey$), "", strbuffer, Len(strbuffer), strfullpath$))
    End Function
    
    Public Sub WriteINI(strsection As String, strkey As String, strkeyvalue As String, strfullpath As String)
        Call WritePrivateProfileString(strsection$, UCase$(strkey$), strkeyvalue$, strfullpath$)
    End Sub
    
    
    Usage
    
    Private Sub Command1_Click()
    'Write
    lang = InputBox("What language will you be using for the duration of the program?")
    If lang <> "" Then
    Call WriteINI("Language.ini", "Language", "" & lang & "", "C:\Language.ini")
    Else
    Exit Sub
    End If
    
    Private Sub Form_Load()
    'Read
    x = ReadINI("Language.ini", "Language", "C:\Language.ini")
    Msgbox "Language: " & x
    End Sub
    Perhaps you should give a list of languages.




  3. #3
    Frenzied Member /\/\isanThr0p's Avatar
    Join Date
    Jul 2000
    Location
    They can't stop us! We're on a misson from God.
    Posts
    1,181
    Ressource files are kind of powerful for multi language support!

    I'd use just a text file not an ini file but doesn't really matter
    Sanity is a full time job

    Puh das war harter Stoff!

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