0
내가 통화를 변환
구글의 금융 변환기을 사용하고
를 사용하는 경우 "입력 문자열이 올바른 형식이 아니었다"얻기하지만 오류 받고 있어요 :구글의 금융 계산기
이input string was not in a correct format
여기 내 코드의를 :
Protected Sub btnGoogleApi_Click(sender As Object, e As EventArgs)
Dim amount As Decimal = 0
Dim fromCurrency As String
Dim toCurrency As String
amount = Decimal.Parse(txtAmount.Text.Trim(), System.Globalization.NumberStyles.Any, CultureInfo.InvariantCulture)
fromCurrency = ddlFrom.SelectedItem.Value
toCurrency = ddlTo.SelectedItem.Value
If amount <> 0 Then
Dim web As New WebClient()
Dim url As String = String.Format("http://www.google.com/finance/converter?a={0}&from={1}&to={2}", amount, fromCurrency.ToUpper(), toCurrency.ToUpper())
Dim response As String = web.DownloadString(url)
Dim regex As New Regex("rhs: \""(\d*.\d*)")
Dim rate As Decimal = System.Convert.ToDecimal(regex.Match(response).Groups(1).Value)
lblMessage.Text = ("Real-Time Rate: 1 " + ddlFrom.SelectedItem.Value & " = " & rate & " ") + ddlTo.SelectedItem.Value
End If
End Sub
디버깅을하셨습니까? 어떤 라인이 끊어 질까요? –
관련없는 참고 사항, 적어도 매우 많은 양이나 매우 적은 금액을 처리하는 경우 통화 값에 소수를 사용하지 않아야합니다. – user2366842
디버거에서 실행 중입니다. 정규식에 맞기 직전의 응답 값은 무엇입니까? – user2366842