A
Adam Honek
Can anyone spot why the below function is failing?
It returns true but when looking inside the INI file there's no new added
section.
****CODE****
Public Function WriteINIFileSection(ByVal sEntryType As String, ByVal
sKeyName As String, ByVal sFilePath As String) As Boolean
'************************************************************
' +++ Purpose
'************************************************************
' Writes a section to an INI file
'************************************************************
'Declare variables
Dim Response As Integer
Try
'Attempt to write the data to the INI file
Response = WritePrivateProfileString(sEntryType, Nothing, vbNullString,
sFilePath)
'The API call failed
If Response = 0 Then
'Return indicating function has failed
WriteINIFileSection = False
Else
'Return indicating function has successfully completed
WriteINIFileSection = True
End If
'If there are any errors catch them
Catch e As Exception
MsgBox("The following error occured: " + e.Message, MsgBoxStyle.Critical,
"Writing account settings section")
'Return indicating function has failed
WriteINIFileSection = False
Exit Function
End Try
End Function
It returns true but when looking inside the INI file there's no new added
section.
****CODE****
Public Function WriteINIFileSection(ByVal sEntryType As String, ByVal
sKeyName As String, ByVal sFilePath As String) As Boolean
'************************************************************
' +++ Purpose
'************************************************************
' Writes a section to an INI file
'************************************************************
'Declare variables
Dim Response As Integer
Try
'Attempt to write the data to the INI file
Response = WritePrivateProfileString(sEntryType, Nothing, vbNullString,
sFilePath)
'The API call failed
If Response = 0 Then
'Return indicating function has failed
WriteINIFileSection = False
Else
'Return indicating function has successfully completed
WriteINIFileSection = True
End If
'If there are any errors catch them
Catch e As Exception
MsgBox("The following error occured: " + e.Message, MsgBoxStyle.Critical,
"Writing account settings section")
'Return indicating function has failed
WriteINIFileSection = False
Exit Function
End Try
End Function