12-09-2006, 04:25 PM
Sure. This is taken from my Snake game.
I made a mod and named it modINI. This just sets read and write ini.
Writing to the INI file.
First part calls it. HIGH SCORES is like the category its labeled under. Then 1. is a sub category... it then writesFinalScore's Caption to that category. Then the last part places it in highscores.ini .
Read INI
HighScore = just sets that value to the following. Then it searches under the Category HIGH SCORES. Then it finds the sub category 1. It takes the value from there and thats the value of HighScore. Then of course the last part is the file it takes the info from.
Anyways pretty simple. You should be able to do whatever you need with this. If you need any more help let me know.
I made a mod and named it modINI. This just sets read and write ini.
Code:
Option Explicit
Public Declare Function WritePrivateProfileString& Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal AppName$, ByVal KeyName$, ByVal keydefault$, ByVal FileName$)
Public Declare Function GetPrivateProfileString& Lib "kernel32" Alias "GetPrivateProfileStringA" (ByVal AppName$, ByVal KeyName$, ByVal keydefault$, ByVal ReturnedString$, ByVal RSSize&, ByVal FileName$)
Public Sub WriteINI(INISection As String, INIKey As String, INIValue As String, INIFile As String)
Call WritePrivateProfileString(INISection, INIKey, INIValue, INIFile)
End Sub
Public Function ReadINI(INISection As String, INIKey As String, INIFile As String) As String
Dim StringBuffer As String
Dim StringBufferSize As Long
StringBuffer = Space$(255)
StringBufferSize = Len(StringBuffer)
StringBufferSize = GetPrivateProfileString(INISection, INIKey, "", StringBuffer, StringBufferSize, INIFile)
If StringBufferSize > 0 Then
ReadINI = Left$(StringBuffer, StringBufferSize)
Else
ReadINI = ""
End If
End Function
Writing to the INI file.
Code:
Call WriteINI("HIGH SCORES", "1.", lblFinalScore.Caption, (App.Path & "\highscores.ini"))
First part calls it. HIGH SCORES is like the category its labeled under. Then 1. is a sub category... it then writesFinalScore's Caption to that category. Then the last part places it in highscores.ini .
Read INI
Code:
HighScore = Trim(ReadINI("HIGH SCORES", "1.", App.Path & "\highscores.ini"))
HighScore = just sets that value to the following. Then it searches under the Category HIGH SCORES. Then it finds the sub category 1. It takes the value from there and thats the value of HighScore. Then of course the last part is the file it takes the info from.
Anyways pretty simple. You should be able to do whatever you need with this. If you need any more help let me know.