|
-
May 4th, 2012, 02:28 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] hey i cant seem to remove the (=) sign
in the .ini file thats made it adds an = ,to the end.
i can change everything to suit me,but removing the = sign.
thanks
Code:
Private Sub Form_Load()
Call ReadScores
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call SaveScores
End Sub
Code:
Option Explicit
'
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
Declare Function WritePrivateProfileString Lib "kernel32" Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, ByVal lpKeyName As String, ByVal lpString As Any, ByVal lpFileName As String) As Long
'
' <<< Public Declarations >>>
'
Public g_tbl_Scores() As String 'table to hold scores
'
' <<< Local Constants >>>
'
Const m_int_SCORES As Integer = 0 'number of scores to track
'
'
' <<< Public Functions >>>
'
Public Function ReadINI(Section, KeyName, FileName As String) As String
Dim sRet As String
sRet = String(255, Chr(0))
ReadINI = Left(sRet, GetPrivateProfileString(Section, ByVal KeyName, "", sRet, Len(sRet), FileName))
End Function
'
Public Function writeini(sSection As String, sKeyName As String, sNewString As String, sFileName) As Integer
Dim variable 'doesn't seem to matter
variable = WritePrivateProfileString(sSection, sKeyName, sNewString, sFileName)
End Function
'
Public Function NormPath(sPath As String, Optional sSeperator As String = "\") As String
If Right(sPath, Len(sSeperator)) = sSeperator Then
NormPath = sPath
Else
NormPath = sPath & sSeperator
End If
End Function
'
Public Sub ReadScores()
'this sub will load the scores from an ini file into
'an array
Dim sFile As String
Dim iControl As Integer
sFile = NormPath(App.Path) & "HighScores.ini"
'
ReDim g_tbl_Scores(m_int_SCORES) 'resize array
'
For iControl = 0 To m_int_SCORES
g_tbl_Scores(iControl) = ReadINI("HighScore", _
"Score.", sFile)
Next iControl
End Sub
'
Public Sub SaveScores()
'this sub will save scores from an array
Dim sFile As String
Dim iControl As Integer
sFile = NormPath(App.Path) & "HighScores.ini"
'
For iControl = 0 To m_int_SCORES
writeini "HighScore", "Score.", _
g_tbl_Scores(iControl), sFile
Next iControl
End Sub
-
May 4th, 2012, 07:13 AM
#2
Thread Starter
Fanatic Member
Re: hey i cant seem to remove the (=) sign
well i think i figured it out like this
Code:
Public Sub ReadScores()
'this sub will load the scores from an ini file into
'an array
Dim sFile As String
Dim holdname As String
Dim holdnums As Integer
Dim iControl As Integer
sFile = NormPath(App.Path) & "HighScores.ini"
'
ReDim g_tbl_Scores(m_int_SCORES) 'resize array
'
For iControl = 0 To m_int_SCORES
If iControl = 0 Then
holdname = "COMPUTER"
holdnums = highnumcomputer
Else
holdname = highnames
holdnums = highnumplayer
End If
g_tbl_Scores(iControl) = ReadINI("HighScore1", holdnums, sFile)
Next iControl
End Sub
Public Sub SaveScores()
'this sub will save scores from an array
Dim sFile As String
Dim holdname As String
Dim holdnums As Integer
Dim iControl As Integer
sFile = NormPath(App.Path) & "HighScores.ini"
'
For iControl = 0 To m_int_SCORES
If iControl = 0 Then
holdname = "COMPUTER"
holdnums = highnumcomputer
Else
holdname = highnames
holdnums = highnumplayer
End If
writeini "HighScore1", holdname, _
g_tbl_Scores(iControl) & holdnums, sFile
Next iControl
End Sub
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|