Getting error while converting string to double: Input string was not in correct format

Select Case LocalMeasuringUnitText 

Case "Currency"
'do the conversion here
Dim ConversionRate As Double = GetConversionRate(_LanguageID)
 
Dim UKValue As Double
'String.Format("{0:c}", SelectedRow(rowloop).Item("TransData").ToString())
Dim varValue As Object = Nothing
Dim Stringvalue As Object = SelectedRow(rowloop).Item("TransData").ToString.Trim
'varValue = Double.TryParse(Stringvalue, varValue)
'CType(Stringvalue, System.Double)
'UKValue = Convert.ToDouble(Stringvalue) / GetConversionRate(ConfigurationManager.AppSettings("DefaultLocale").ToLower)
'UKValue = GetCurrencyinDouble(Stringvalue) / GetConversionRate(ConfigurationManager.AppSettings("DefaultLocale").ToLower)
'Dim varstr = TempCulture.NumberFormat.CurrencySymbol & UKValue * ConversionRate
If Not IsDBNull(Stringvalue) Then
UKValue = System.Math.Round(Double.Parse(Stringvalue), 2) / GetConversionRate(ConfigurationManager.AppSettings("DefaultLocale").ToLower)
End If
 
FirstRow(FinalData.Columns.IndexOf(TransObArray(TransLoop).ColumnName)) = UKValue * ConversionRate
'FirstRow(FinalData.Columns.IndexOf(TransObArray(TransLoop).ColumnName)) = SelectedRow(rowloop).Item("TransData")
Case Else
FirstRow(FinalData.Columns.IndexOf(TransObArray(TransLoop).ColumnName)) = SelectedRow(rowloop).Item("TransData")
End Select
0
RSPreran
9/1/2008 11:23:27 AM
📁 asp.net.getting-started
📃 91979 articles.
⭐ 4 followers.

💬 2 Replies
👁️‍🗨️ 1505 Views



 Try this
 
Convert.ToDouble(stringValue);
 
cheers !!!
Rukshan Samanathilaka

SHAN
0
rukshansamanthilaka
9/1/2008 12:07:55 PM

You usually have these exceptions show up even when the input string is all fine is the Localization-Globalization.
You can se the thread culture prior to conversion using the Thread.SetCulture and SetUICulture or similar methods so that it treats string inputs in a localized manner, you can also specify it as part of the ValueType.Parse methods so that you do not have to do it for the complete thread.
Hope it resolves your problem, it has worked for me!

Regards,

Digvijay
http://www.digvijay.eu
http://blog.digvijay.eu

--------
Please remember to Mark As Answer if this post answered your question!
0
digvijay
9/1/2008 12:45:21 PM
Reply: