-
Hi, I have been given modules to read and write to .ini files before. But when ever I have gone to call on the functions I have gotten errors.
So can someone please give me a code to go into a module for the read and write functions. and explain how to use them?
thanx in advance.
-
Try this Mr. JTech!
________________________________________________________
Option Explicit
Private Declare Function OSGetPrivateProfileString 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
Private Declare Function OSWritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As Any, ByVal lpString As Any, ByVal lpFileName As String) As Long
Private Sub CmdGet_Click()
'PURPOSE: Get data from your text files
'Text1.Text = The name of the bracket section
'Text2.Text = The name of the field
'An error message
'Where to assign the answer to
'The lengh of the answer
'The location of the text file
Dim str_Nitro As String * 50
Call OSGetPrivateProfileString(Text1.Text, Text2.Text, "There is an error!", str_Nitro, Len(str_Nitro), CurDir & "\winzip32.ini")
lblAnswer.Caption = str_Nitro
End Sub
Private Sub CmdWrite_Click()
'PURPOSE: Write to your text file
'Text4.Text = The name of the bracket section
'Text5.Text = The name of the field
'Text6.Text = The new value for that field
'The location of the text file
If Text1.Text <> "" Then
Call OSWritePrivateProfileString(Text4.Text, Text5.Text, Text6.Text, CurDir & "\winzip32.ini")
End If
Text6.Text = ""
lblAnswer.Caption = ""
End Sub
[Edited by Nitro on 04-08-2000 at 04:39 AM]