I'm not very skilled with visual basics and I'm learning how to use it at school. I'm making a currency converter and was a bit stuck.
Basically my currency converter has the option to update currency exchange rates using a button and when you click that an input box comes up saying "Please enter the exchange rate" and then that value goes into the variable "exchange rate". Simple and that works. However I also have to have default currency exchange rates so if the user doesn't click on the 'update exchange rate' button then the new currency will be able to be calculated with the default exchange rate. So I was wondering
1) How do I check if the user didn't enter a new updated exchange rate? and then set that as the overall exchange rate? Here's my current coding, please help:
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
Dim amountToConvert As Single
Dim currencyConvertTo As String
Dim currenyConvertFrom As String
amountToConvert = txtAmount.Text
currencyConvertTo = cmbConvertTo.Text
currenyConvertFrom = cmbConvertFrom.Text
exchangerate = InputBox("Please enter the exchange rate between " & currencyConvertTo & " and " & currenyConvertFrom)
If exchangerate = "" And currencyConvertTo = "British Pound (GDP)" Then
exchangerate = exchangerateGDP
ElseIf exchangerate = "" And currencyConvertTo = "American Dollar (USD)" Then
exchangerate = exchangerateUSD
ElseIf exchangerate = "" And currencyConvertTo = "Euro (EUR)" Then
exchangerate = exchangerateEUR
ElseIf exchangerate = "" And currencyConvertTo = "Japenese Yen (JPY)" Then
exchangerate = exchangerateJPY
End If
End Sub
BUT.......it said I cant do the If exchangerate = "" because I'm using single not a string, so what do I put instead of "" to check if the field wasn't entered?
THANKYOU so much in advance!
Basically my currency converter has the option to update currency exchange rates using a button and when you click that an input box comes up saying "Please enter the exchange rate" and then that value goes into the variable "exchange rate". Simple and that works. However I also have to have default currency exchange rates so if the user doesn't click on the 'update exchange rate' button then the new currency will be able to be calculated with the default exchange rate. So I was wondering
1) How do I check if the user didn't enter a new updated exchange rate? and then set that as the overall exchange rate? Here's my current coding, please help:
Private Sub btnUpdate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnUpdate.Click
Dim amountToConvert As Single
Dim currencyConvertTo As String
Dim currenyConvertFrom As String
amountToConvert = txtAmount.Text
currencyConvertTo = cmbConvertTo.Text
currenyConvertFrom = cmbConvertFrom.Text
exchangerate = InputBox("Please enter the exchange rate between " & currencyConvertTo & " and " & currenyConvertFrom)
If exchangerate = "" And currencyConvertTo = "British Pound (GDP)" Then
exchangerate = exchangerateGDP
ElseIf exchangerate = "" And currencyConvertTo = "American Dollar (USD)" Then
exchangerate = exchangerateUSD
ElseIf exchangerate = "" And currencyConvertTo = "Euro (EUR)" Then
exchangerate = exchangerateEUR
ElseIf exchangerate = "" And currencyConvertTo = "Japenese Yen (JPY)" Then
exchangerate = exchangerateJPY
End If
End Sub
BUT.......it said I cant do the If exchangerate = "" because I'm using single not a string, so what do I put instead of "" to check if the field wasn't entered?
THANKYOU so much in advance!