Results 1 to 2 of 2

Thread: Great INI Problem

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jun 1999
    Posts
    16

    Post

    I got a really weird problem while using ini's, and there it is: In a form to get prices and calculate them, i added this line to make the total price appear in this manner: Amount X unit price = total price

    Line of code:
    lstTotal.AddItem (txtQuantidade.Text & " X " & Trim(Temp) & " = " & txtQuantidade * Trim(Temp))

    Here is the complete command code

    Dim ret As Long
    Dim Temp As String * 50
    Dim lpAppName As String, lpKeyName As String, lpDefault As String, lpFileName As String

    lpAppName = "Precos"
    lpKeyName = txtNome.Text
    lpDefault = "c:\Util\Lojas\preview.ini"
    lpFileName = "c:\Util\Lojas\preview.ini"

    ret = GetPrivateProfileString(lpAppName, lpKeyName, lpDefault, Temp, Len(Temp), lpFileName)

    If ret = 0 Then
    Beep
    ElseIf txtQuantidade = "1" Then
    lstUnitario.AddItem Trim(Temp)
    lstTotal.AddItem ("1 X " & Trim(Temp))
    lstProduto.AddItem txtNome.Text
    lstQuantidade.AddItem txtQuantidade.Text
    Text1.Text = Text1.Text + Trim(Temp)
    ElseIf txtQuantidade = "0" Then
    MsgBox "Quantidade é igual a 0!!", vbOKOnly, "Erro de Compreensão"
    Else
    lstUnitario.AddItem Trim(Temp)
    lstTotal.AddItem (txtQuantidade.Text & " X " & Trim(Temp) & " = " & txtQuantidade * Trim(Temp))
    lstProduto.AddItem txtNome.Text
    lstQuantidade.AddItem txtQuantidade.Text
    Text1.Text = Text1.Text + (txtQuantidade * Trim(Temp))
    End If

    Last question: If the Key name I specified to the INI doesn't exists, how could I get to the project say that it not exist? It get a weird bug, saying that the price is the path to the ini.

    Very,Very Thanks


    ------------------
    --Alex

  2. #2
    Serge's Avatar
    Join Date
    Feb 1999
    Location
    Scottsdale, Arizona, USA
    Posts
    2,744

    Post

    It happens because you use this:

    lpDefault = "c:\Util\Lojas\preview.ini"


    Then you use this variable in the GetPrivateProfile API. It means that if it doesn't find the Key it will return lpDefault (which in your case the path to the INI file instead of the value)



    ------------------

    Serge

    Software Developer
    Serge_Dymkov@vertexinc.com
    Access8484@aol.com
    ICQ#: 51055819


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width