P
Paul
Hay NG!
I want to read an ini-file an put all lines in a collectionobject.
everything is alright if i search the coll-object with an numeric index
if i try to do this with an alpha-key i got an error(5)
here my code
public colINI as Collection
Public Function BReadINIFile() As Boolean
Dim sBuffer As String, sSectionName As String, sKey As String
Dim sColKey As String, sColValue As String
Dim iX As Integer
Dim v As Variant, s As String
On Error GoTo fuError
BReadINIFile = False
set colINI=new Collection
Open m_sINIFileName For Input As #1
While Not EOF(1)
Line Input #1, sBuffer
If (sBuffer <> "") Then
If (Left$(sBuffer, 1) = "[") Then
iX = InStr(sBuffer, "]")
sSectionName = Left$(sBuffer, iX)
Else
iX = InStr(sBuffer, "=")
sKey = Left$(sBuffer, iX - 1)
sColKey = sSectionName & "[" & sKey & "]"
sColValue = Right$(sBuffer, Len(sBuffer) - iX)
colINI.Add Item:=Trim$(CStr(sColValue)),
Key:=Trim$(CStr(sKey))
End If
End If
Wend
Close #1
'only for testing i tried to get the last added key !
s = colINI.Item(CStr(sColKey))
BReadINIFile = True
fuExit:
Exit Function
fuError:
vShowError "BReadINIFile"
GoTo fuExit
End Function
whats wrong ?
thx for your help!
Paul
I want to read an ini-file an put all lines in a collectionobject.
everything is alright if i search the coll-object with an numeric index
if i try to do this with an alpha-key i got an error(5)
here my code
public colINI as Collection
Public Function BReadINIFile() As Boolean
Dim sBuffer As String, sSectionName As String, sKey As String
Dim sColKey As String, sColValue As String
Dim iX As Integer
Dim v As Variant, s As String
On Error GoTo fuError
BReadINIFile = False
set colINI=new Collection
Open m_sINIFileName For Input As #1
While Not EOF(1)
Line Input #1, sBuffer
If (sBuffer <> "") Then
If (Left$(sBuffer, 1) = "[") Then
iX = InStr(sBuffer, "]")
sSectionName = Left$(sBuffer, iX)
Else
iX = InStr(sBuffer, "=")
sKey = Left$(sBuffer, iX - 1)
sColKey = sSectionName & "[" & sKey & "]"
sColValue = Right$(sBuffer, Len(sBuffer) - iX)
colINI.Add Item:=Trim$(CStr(sColValue)),
Key:=Trim$(CStr(sKey))
End If
End If
Wend
Close #1
'only for testing i tried to get the last added key !
s = colINI.Item(CStr(sColKey))
BReadINIFile = True
fuExit:
Exit Function
fuError:
vShowError "BReadINIFile"
GoTo fuExit
End Function
whats wrong ?
thx for your help!
Paul