|
-
Nov 25th, 1999, 09:33 AM
#1
Thread Starter
Junior Member
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
-
Nov 26th, 1999, 06:57 AM
#2
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
[email protected]
[email protected]
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|