|
-
Apr 9th, 2006, 04:29 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] School Work
I have this exercise to do but im stumped at what else to do next.
We have to make a simple Currency converter, i get how to change the currency from US dollars to yen,euros, ans pesos but here is the tricky part,
the user types in the amount of US dollars they want converted but then the user has to type in Yen, Euro, Pasos in a text then when you hit convert i will convert it to what ever the user typed in the Currency text box,
but i dont no how to make the program read what the user typed in for currency. The teacher wants us to use the If..ElseIf..ElseIf statements and to display the answer in the lbloutput box is sapose to be displayed by using the String.Format method which i get.
lol here is all i got for the begining
VB Code:
Private Sub btnConvert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConvert.Click
Dim dollars As New Double
Dim amount As New Decimal
dollars = Val(txtValue.Text)
amount = Val(txtCurrency.Text)
-
Apr 9th, 2006, 04:42 PM
#2
Thread Starter
Hyperactive Member
Re: School Work
ok i got an understanding now i for got to add the "" around the word Yen example "Yen", now when i do math part i get a "End of statement Explected"
here is the code.
VB Code:
If amount = "Yen" Then
val(txtvalue.Text) [B]* 120[/B]
the part in bold is under lined in blue.
-
Apr 9th, 2006, 04:52 PM
#3
Junior Member
Re: School Work
well its underlined like that because your just multiplying the numbers and not telling the computer to do anything with them.
DAve
-
Apr 9th, 2006, 05:31 PM
#4
Thread Starter
Hyperactive Member
I redid all the code an it works like a charm now here is the code i did.
VB Code:
Private Sub btnConvert_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConvert.Click
If (txtCurrency.Text = "Yen") Then 'If the user types in Yen it will multiply the users value by 120
lbloutput.Text = _
Val(txtValue.Text) * 120
ElseIf (txtCurrency.Text = "Euros") Then 'If the user types in Euros it will Multiply the users value by 1.02
lbloutput.Text = _
Val(txtValue.Text) * 1.02
ElseIf (txtCurrency.Text = "Pesos") Then 'If the user types in Pesos it will Multiply the Users Value by 10
lbloutput.Text = _
Val(txtValue.Text) * 10
End If
End Sub
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
|