-
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
-
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.
-
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