|
-
Nov 15th, 2001, 02:20 PM
#1
Thread Starter
New Member
Addition problems
I am creating a currency converter that not only converts the currency it also adds the total amount converted together and displays it in US$. My problem is that when I enter an amount to be converted it adds it to my total converted box, but when I add another amount to be converted it replaces the first amount instead of adding them together. How can I fix this? Also, when I close the application I lose all the previous data. How can I save this? I've have heard "SaveSetting" but I don't know how to use it.
Thanks!!!
-
Nov 15th, 2001, 02:25 PM
#2
Post some code...
SaveSetting is easy
SaveSetting "AppName","SomeName","DataDescription", Data
ex:
Data = txtTotal.text
SaveSetting "ConverterApp","Settings","TotalConverted",Data
to get it back
Data = Getsetting("ConverterApp","Settings","TotalConverted","")
in getsetting the last entry is the 'Default' meaning if the field is not there in the registry..it will set it to this value...in this case nothing
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Nov 15th, 2001, 02:43 PM
#3
Thread Starter
New Member
I tried it...
I tried it, but it gives me an "invalid outside procedure" error.
Keep in mind that I don't really know what I am doing, and the book I have mentions nothing of "SaveSetting"
here is my code below if anyone wants to look.
Data = lblAmountSpent.Caption
SaveSetting "Currency Converter", "Settings", "TotalConverted", Data
Data = GetSetting("Currency Converter", "Settings", "TotalConverted", "")
Dim rate As Currency
Private Sub Command1_Click()
Text3.Text = Val(Text2.Text * rate)
Option6.Value = 0
lblAmountSpent.Caption = Format$(Text2.Text, "currency")
End Sub
Private Sub Option1_Click()
rate = 2170
If Option1.Value = 1 Then Text3.Text = rate * Text3.Text
cboLog.AddItem Option1.Caption & Text3.Text
End Sub
Private Sub Option2_Click()
rate = 2.19
If Option2.Value = 1 Then Text3.Text = rate * Text3.Text
End Sub
Private Sub Option3_Click()
rate = 7.35
If Option3.Value = 1 Then Text3.Text = rate * Text3.Text
End Sub
Private Sub Option4_Click()
rate = 0.68
If Option4.Value = 1 Then Text3.Text = rate * Text3.Text
End Sub
Private Sub Option5_Click()
rate = 1.12
If Option5.Value = 1 Then Text3.Text = rate * Text3.Text
End Sub
-
Nov 15th, 2001, 02:57 PM
#4
hmmm.. are you using VB6?
is it erroring on the Savesetting?
also...Dont use SaveSetting...then GetSetting right after that..
When you close the app (Form_unload) use the
SaveSetting to store the value
then in the Form_Load() event use the GetSetting to retrieve it.
try this...
start a new project...
add a command button
paste this code in
VB Code:
Private Sub Command1_Click()
MsgBox GetSetting("MyApp", "Startup", "Left", "")
End Sub
Private Sub Form_Load()
SaveSetting "MyApp", "Startup", "Left", 50
End Sub
then run it..and click the button..does it show 50?
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Nov 15th, 2001, 03:16 PM
#5
Thread Starter
New Member
it does...
It does say 50...I am using VB 6.
So what does "Left" mean?
Can I change "Left" to what I want it to save and return? Like if I want it to save and return the value of lblAmountSpent?
Thanks
-
Nov 15th, 2001, 03:23 PM
#6
i think i got your problem....
try this
VB Code:
Dim Data As String
Data = Cstr(lblAmountSpent.Caption ) 'use the Cstr() to make sure its a string
SaveSetting "Currency Converter", "Settings", "TotalConverted", Data
savesetting only allows a string to be entered...so that may be why it broke before...
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Nov 15th, 2001, 03:48 PM
#7
Thread Starter
New Member
still get error message...
I still get the same error message...Do you think I am putting the code in the wrong place? Also, If I use the SaveSetting will it help me keep a running total of amount converted. Now if I put in $600 dollars and convert it and then convert another $300 it will not add the two, it just replaces the first number. I attached my program files if you want to take a look...
Thanks for all you help so far!!!
-
Nov 15th, 2001, 03:52 PM
#8
add it to the combo box?
(I found the first problem...you have the code in the general declarations section)
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Nov 15th, 2001, 03:56 PM
#9
Thread Starter
New Member
where...
Where should I put the code? Under the Command button or the AmountSpent label?
-
Nov 15th, 2001, 04:00 PM
#10
hang on..I see what your doing...
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Nov 15th, 2001, 04:07 PM
#11
ok here... all fixed..and a few tweaks
a delete button to clear the total
and a formatted textbox to display the converted amounts nicley
you still have to finish adding to the combo box
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Nov 15th, 2001, 06:18 PM
#12
Thread Starter
New Member
Awesome!!!
thank you, I see what's happening now. Thanks for leaving the comments in there. I got the Converted amount and type to add in the combo box but there is no space between them. (ie Euro2436 instead of Euro 2436.
the i wrote is
cboLog.Additem Option1.Caption + text2.text
i tried to do it this way but i keep getting errors.
cboLog.Additem Option1.Caption + & " " & text2.text
I thought the &" "& would be a space.
But anyway thank you very much!!!
-
Nov 15th, 2001, 07:42 PM
#13
you were close.
never use + to concantinate (spelling?) (add) 2 strings together always use &
cboLog.Additem Option1.Caption & " " & text2.text
I removed the + from that line..that should work fine
JPnyc rocks!! (Just ask him!)
If u have your answer please go to the thread tools and click "Mark Thread Resolved"
-
Nov 15th, 2001, 07:49 PM
#14
Thread Starter
New Member
yep I got it...
Thanks, How would I set an error message to appear if the user does not have a currency type selected?
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
|