Advertisement

09.05.2008 at 05:12PM PDT, ID: 23708038
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.0

ini file not saving defaults

Asked by isnoend2001 in Visual Basic Programming

I have been using this class ini file for sometime and the saving defaults has never worked. I now need it to work. It just not save a default value, What is causing this ?
Private m_sPath           As String
Private m_sKey            As String
Private m_sSection        As String
Private m_sDefault        As String
Private m_lLastReturnCode As Long
' Profile String functions:


    Private Declare Function WritePrivateProfileString _
                    Lib "kernel32" _
                    Alias "WritePrivateProfileStringA" (ByVal lpApplicationName As String, _
                                                        ByVal lpKeyName As Any, _
                                                        ByVal lpString As Any, _
                                                        ByVal lpFileName As String) As Long
    Private Declare Function GetPrivateProfileString _
                    Lib "kernel32" _
                    Alias "GetPrivateProfileStringA" (ByVal lpApplicationName As Any, _
                                                      ByVal lpKeyName As Any, _
                                                      ByVal lpDefault As Any, _
                                                      ByVal lpReturnedString As String, _
                                                      ByVal nSize As Long, _
                                                      ByVal lpFileName As String) As Long


Property Get LastReturnCode() As Long
    LastReturnCode = m_lLastReturnCode

End Property
Property Get success() As Boolean
    success = (m_lLastReturnCode <> 0)

End Property
Property Let Default(sDefault As String)
    m_sDefault = sDefault

End Property
Property Get Default() As String
    Default = m_sDefault

End Property
Property Let Path(sPath As String)
    m_sPath = sPath

End Property
Property Get Path() As String
    Path = m_sPath

End Property
Property Let Key(sKey As String)
    m_sKey = sKey

End Property
Property Get Key() As String
    Key = m_sKey

End Property
Property Let Section(sSection As String)
    m_sSection = sSection

End Property
Property Get Section() As String
    Section = m_sSection

End Property
Property Get Value() As String
        Dim sBuf     As String
        Dim iSize    As String
        Dim iRetCode As Integer

    sBuf = space$(255)
    iSize = Len(sBuf)
    iRetCode = GetPrivateProfileString(m_sSection, m_sKey, m_sDefault, sBuf, iSize, m_sPath)

    If (iSize > 0) Then
        Value = Left$(sBuf, iRetCode)
    Else
        Value = ""
    End If

End Property
Property Let Value(sValue As String)
        Dim iPos As Integer
    ' Strip chr$(0):
    iPos = InStr(sValue, Chr$(0))
    Do While iPos <> 0
        sValue = Left$(sValue, (iPos - 1)) & Mid$(sValue, (iPos + 1))
        iPos = InStr(sValue, Chr$(0))
    Loop
    'MsgBox m_sPath
    m_lLastReturnCode = WritePrivateProfileString(m_sSection, m_sKey, sValue, m_sPath)
 
End Property
Public Sub DeleteKey()
    m_lLastReturnCode = WritePrivateProfileString(m_sSection, m_sKey, 0&, m_sPath)
End Sub

Public Sub DeleteSection()
    m_lLastReturnCode = WritePrivateProfileString(m_sSection, 0&, 0&, m_sPath)
End Sub
Property Get IniSection() As String
        Dim sBuf     As String
        Dim iSize    As String
        Dim iRetCode As Integer

    sBuf = space$(8192)
    iSize = Len(sBuf)
    iRetCode = GetPrivateProfileString(m_sSection, 0&, m_sDefault, sBuf, iSize, m_sPath)
    If (iSize > 0) Then
        IniSection = Left$(sBuf, iRetCode)
    Else
        IniSection = ""
    End If

End Property
Property Let IniSection(sSection As String)
    m_lLastReturnCode = WritePrivateProfileString(m_sSection, 0&, sSection, m_sPath)

End Property
Property Get Sections() As String
        Dim sBuf     As String
        Dim iSize    As String
        Dim iRetCode As Integer

    sBuf = space$(8192)
    iSize = Len(sBuf)
    iRetCode = GetPrivateProfileString(0&, 0&, m_sDefault, sBuf, iSize, m_sPath)
    If (iSize > 0) Then
        Sections = Left$(sBuf, iRetCode)
    Else
        Sections = ""
    End If

End Property
Start Free Trial
 
Loading Advertisement...
 
[+][-]09.05.2008 at 11:22PM PDT, ID: 22406290

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.05.2008 at 11:33PM PDT, ID: 22406311

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.06.2008 at 01:19AM PDT, ID: 22406545

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]09.06.2008 at 01:54AM PDT, ID: 22406631

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zone: Visual Basic Programming
Sign Up Now!
Solution Provided By: egl1044
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628