Click here to Skip to main content
15,891,033 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have a project,a simple currency converter.. i want to convert upto five currency,i have one textbox where u can type ur input and i want to appear the 5 result in 5 label.. i have only one button and i want o ask on how to put the code in the button that it will not conflict to each other.. here is my code:



label1.text=val(textbox1.text)* 54 (FOR VALUE OF US DOLLAR)
label2.text=val(textbox1.text)* 43 (FOR VALUE OF EURO)
label3.text=val(textbox1.text)* 45 (FOR VALUE OF DINAR)
label4.text=val(textbox1.text)* 52 (FOR VALUE OF YEN)
label5.text=val(textbox1.text)* 65 (FOR VALUE OF HONGKONG DOLLAR)

if i put it in one button there is possible to conflict each other? thanks a lot. you can email me at [DELETED]@yahoo.com.. GOD BLESS


[edit]Email deleted - OriginalGriff[/edit]
Posted
Updated 14-Jul-12 20:07pm
v2
Comments
OriginalGriff 15-Jul-12 2:07am    
Never post your email address in any forum, unless you really like spam! If anyone replies to you, you will receive an email to let you know

1 solution

It should not conflict (assuming that the bit in brackets is intended as a comment), each label is independant.

However, I would convert the textbox1.Text value to a numeric value once before using the converted value in each line:
VB
Dim baseCurrency As Double
If Double.TryParse(textbox1.Text, baseCurrency) Then
    label1.text = (baseCurrency * 54).ToString()
    ...
End If
In addition, I wouldn't use "magic numbers" for the exchange rate... Rates tend to change on a minute by minute basis, so your software will be out of date within seconds of you compiling it!
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900