Public Class CurrencyConverterForm
Private Sub convertButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles convertButton.Click
' delared varibles
Dim amount As Decimal
Dim result As Decimal
Dim dollar As Double
Dim yen As Integer
Dim euros As Integer
Dim pesos As Integer
amount = Val(currencyTextBox.Text)
dollar = Val(dollarsTextBox.Text)
result = Val(convertedResultLabel.Text)
If amount = yen Then
result = 76.9 * dollar
ElseIf amount = euros Then
result = 0.74 * dollar
ElseIf amount = pesos Then
result = 14 * dollar
End If
convertedResultLabel.Text = String.Format("{0:F}", result)
dollarsTextBox.Focus()
End Sub
Private Sub currencyTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles currencyTextBox.TextChanged
convertedResultLabel.Text = String.Empty
End Sub
Private Sub dollarsTextBox_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles dollarsTextBox.TextChanged
convertedResultLabel.Text = String.Empty
End Sub
End Class ' CurrencyConverterForm
Currency Converter
Page 1 of 113 Replies - 239 Views - Last Post: 23 February 2013 - 07:09 AM
#1
Currency Converter
Posted 22 February 2013 - 10:40 PM
Replies To: Currency Converter
#2
Re: Currency Converter
Posted 22 February 2013 - 10:54 PM
Debugging Skills
This post has been edited by AdamSpeight2008: 22 February 2013 - 10:58 PM
#3
Re: Currency Converter
Posted 22 February 2013 - 11:19 PM
#4
Re: Currency Converter
Posted 22 February 2013 - 11:24 PM
If not what differs?
#5
Re: Currency Converter
Posted 22 February 2013 - 11:27 PM
nelliegirl, on 22 February 2013 - 11:40 PM, said:
In your code, you have a line: If amount = yen Then
Ask yourself what decimal value "yen" has.
There are a few other lines of similar errors.
Above your Class statement, I would recommend putting two lines:
Option Explicit On Option Strict On
Now look at your code again. Fix all the errors that are shown by the wiggly underline. Hint: At the end of the wiggly underline, you'll find a short red underline. driving your mouse cursor over that will cause an exclamation mark to show up. Clicking on it will often bring up a way to fix it. Clicking on that will apply the fix.
As well, you should learn how to debug your code. See our Debugging Tutorial.
#6
Re: Currency Converter
Posted 22 February 2013 - 11:42 PM
#7
Re: Currency Converter
Posted 22 February 2013 - 11:54 PM
#8
Re: Currency Converter
Posted 23 February 2013 - 12:09 AM
#9
Re: Currency Converter
Posted 23 February 2013 - 12:12 AM
If amount = yen Then result = 76.9 * dollar ElseIf amount = euros Then result = 0.74 * dollar ElseIf amount = pesos Then result = 14 * dollar Else ' What to do if all of the above are false. End If
This post has been edited by AdamSpeight2008: 23 February 2013 - 12:14 AM
#10
Re: Currency Converter
Posted 23 February 2013 - 12:19 AM
#11
Re: Currency Converter
Posted 23 February 2013 - 12:35 AM
This will result in the variable with a value of zero (0).
This post has been edited by AdamSpeight2008: 23 February 2013 - 12:39 AM
#12
Re: Currency Converter
Posted 23 February 2013 - 12:44 AM
#13
Re: Currency Converter
Posted 23 February 2013 - 12:56 AM
Simplify the problem. Go create a CONSOLE application (no forms at all).
Then think about the algorithm. Then think about the code.
What types are going to use.
This post has been edited by AdamSpeight2008: 23 February 2013 - 12:56 AM
#14
Re: Currency Converter
Posted 23 February 2013 - 07:09 AM
nelliegirl, on 23 February 2013 - 01:19 AM, said:
Again, go back to my post, and put those two lines in. You WILL have errors on those If statements. Look at what the editor is telling you about those errors. Fix them. You'll make progress.
|
|

New Topic/Question
Reply




MultiQuote





|