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

9/1/2008 11:23:27 AM 91979 articles. 4 followers. Follow

2 Replies

Similar Articles

[PageSpeed] 20
Get it on Google Play
Get it on Apple App Store

 Try this




cheers !!!

Rukshan Samanathilaka

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!



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

Similar Artilces:

I am getting error "Input string was not in a correct format."
 I am trying to load Schema file and Xml file but getting this errorSystem.FormatException: Input string was not in a correct format.for this line:   DataSet ds = new DataSet();   ds.ReadXmlSchema(Server.MapPath(SchemaFileName));   ds.ReadXml(Server.MapPath(FileName));            // here i am getting the error.I checked the FIileName string and it was alright.While i comment the line that load the Schema everything is alright so i assume the problem is in the Schema.this is how the xml fi...

Getting an "Input string was not in a correct format" error
I've got a ASP.NET 2.0 application with a FormView control on it.  I've placed textboxes and other controls onto the InsertItemTemplate, and wired them up to save to the backend SQL Server 2005 DB.  I want to test how it will behave if a user does not do the "right thing".  For example, I've got a dropdown list with "Yes", "No", "Maybe", etc.  If they user selects "Yes", then they are to fill in a textbox.  However, if they select anything other than "Yes", then no matter what they put into the t...

FormView Textbox getting error: Input string was not in a correct format.
I have a formview with multiple textboxes that updates a database using an objectdatasource. I get the error in edit mode when I click the update button. When I comment out all textboxes and dropdowns, the update is successful (which means all my fields are empty in the database). and when I add the first dropdown, again it is successful. But when I add the FirstName textbox and then try to update I get the error "Input string was not in a correct format". In the Database, the FirstName Field format is "nvarchar(25)" and in my ObjectdataSource I have the up...

Help, I get this error, "Input string was not in a correct format."
First off, thank you for any responses.  I find this area very helpful when I hit a wall such as the one i'm at right now. I created a form that in part, grabs a student's id from an SQL database and returns the information in a DataGrid.  When I press the submit button I get this error. Server Error in '/URAPvbx' Application. Input string was not in a correct format. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated i...

Input string was not in a correct format, attempting to convert string
I keep getting "Input string was not in a correct format" on the line below that begins with int hold, Prod is a label that holds an int value, say in this case 407, I can track the value through debug and it is correct but when this line runs I get this same error everytime, I can isolate out the Prod.Text and it works fine so the error develops in the Int32.Parse, I have also tried using the convert.toint32 method but I got the exact same error private void addToCart_Click(object sender, System.Web.UI.ImageClickEventArgs e) { int hold=Int32.Parse(Prod.Text.ToString(...

Getting Error: DropDownList' cannot be converted to 'String' How should I format this?
Dear Forum,I am getting an error when I add a drop down list to my forms. The textboxes were working fine.  It is just this drop down list for "Ticketvendor". Thanks, Jeff WoodBoise, ID------------------------------------------------------------------------------------------Compiler Error Message: BC30311: Value of type 'System.Web.UI.WebControls.DropDownList' cannot be converted to 'String'.Source Error: Line 146: ShowtimeLabel.Text = Showtime Line 147: PriceLabel.Text = Price Line 148: Ticketvendor.SelectedItem.Value = Ticketvendor Line 149: Ticke...

get Format of the initialization string does not conform to specification starting at index 0. error
Hi, I have a page in which I have the following line in VB, my "abcConnectionString" is set in the web.config file. But when I click on the button, I get this error: Format of the initialization string does not conform to specification starting at index 0. What should I do? thank you.Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim txt1 As TextBox = Me.FindControl("TextBox1") ' txt1.Text = "i will start"Dim myConnection As New SqlConnection("abcConnectionString") myConnection.Open()D...

after 3.0.13 upgrade, HOST login nets CRITICAL ERROR..INPUT STRING..NOT IN..CORRECT FORMAT Performed 3.0.13 upgrade, edited SiteSqlServer key back into Web.config.Extended pause upon loading site occurred as it should, but no expected resulting upgrade page displayed.Then after submitting login user HOST, pw, this error displays...     A critical error has occurred    Input string was not in a correct format. Dropping back to .12 dnn netted same results, so I presume db got evolved by the upgrade process above, even though no upgrade confirmation page ensue...

How to copy strings in array of strings....I am getting some errors....
Hi, I want to display all the file names that are present in a specified directory....say "C:\data" in a GridView for that I am using the following: Imports System.IOPartial Class _Default Inherits System.Web.UI.PageProtected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click Dim strFileSize As String = ""Dim di As New IO.DirectoryInfo("C:\data") Dim aryFi As IO.FileInfo() = di.GetFiles()Dim fi As IO.FileInfo For Each fi In aryFi strFileSize = (Math.Round(fi.Length / 1024)).ToString() Response.Write(fi.Name)...

Input string was not in a correct format
Hi I wrote the following code, and this code is working fine in my local webapplication, but when i deployed this into development server, it is giving the error "Input string was not in a correct format". Please help me and tell me where my code is throwing error. using CyberSource.Clients; using System; using System.Data; using System.Data.SqlClient; using System.Configuration; using System.Collections; using System.Web; using System.Net; using System.Net.Mail; using System.Web.Security; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.WebCo...

Error Input string was not in a correct format
When I run the "add new" on this form, I get a system error: "Input string was not in a correct format"... "System.Data.DataColumn.set_Item(Int32 record, Object value)Couldn't store <> in siteID Column. Expected type is Decimal.". It was expecting a decimal yet I don't see any where a decimal value was declared. I used the webmatrix "editable data grid" template and replaced fields and variables with my own. I'm using MSDE/SQL7, the siteID field in SQL is set for numeric, incrementing by 1, primary key. Thanks for any help. The for...

Input string was not in a correct format error
Hello All,  I know this may be a simple problem but i've been trying everything. I am trying to send a field count as a variable from one page to another and using it in a loop. Unfortunately I get the Input String error. I want to use the variable in a For Loop, or any loop for that matter. If anyone could suggest any any solutions that would be great. The code is as follows: Dim count As Integer = rs.Fields.Count ...  Then the following page:  ....  For i To count ... Kind Regards Shahid That error is not related to any of the code you are showing. An &qu...

Error:Input string is not in correct format
Developed   in aspx.csDb:sql2000.I am trying to get the selected "price" from gridview and display that in labels.after running the application.whenever i click's on  button1.It showing error :Input string is not in correct format.(pointing at "double j=.............")Help me to resolve this query.Table: CREATE TABLE [L4I_Subscriptions] (    [Subscription_Id] [int] IDENTITY (1, 1) NOT NULL ,    [Subscription_name] [varchar] (200) COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL ,    [Subscription_price] [money] ...

Input string was not in a correct format. error
I have a page where user can insert a new record, i use stroed procedures:ALTER PROCEDURE [dbo].[sp_InsertTypes] @Type varchar(10), @Type_Desc varchar(35), @Contact_Name varchar(20), @Contact_Ad1 varchar(25), @Contact_Ad2 varchar(25), @Contact_City varchar(10), @Contact_Phone varchar(12), @Contact_Fax varchar(12), @Contact_Email varchar(35) Insert into dbo.Types (Type,Type_Desc,Contact_Name,Contact_Ad1,Contact_Ad2,Contact_City,Contact_Phone, Contact_Fax,Contact_Email) values (@Type,@Type_Desc,@Contact_Name,@Contact_Ad1,@Contact_Ad2,@Contact_City, @Contact_Phone, @Contact_Fax,@Co...

Web resources about - Getting error while converting string to double: Input string was not in correct format -

PastBook’s Integration Eases Process Of Converting Facebook Content To Books
PastBook , one of several companies that allow Facebook users to publish their content on the social network in actual books , announced the ...

Facebook No Longer Converting Groups Into Pages
Back when Facebook first launched Facebook Pages, many businesses and brands who had built up substantial audiences in their Facebook Groups ...

Zwartz Laminating-Converting B.V. on the App Store on iTunes
Get Zwartz Laminating-Converting B.V. on the App Store. See screenshots and ratings, and read customer reviews.

"Occupier" Thanked Former Soviet Citizen for "Converting" Him to Capitalism, Pro-Israel, Pro-USA - YouTube ...
May Day Demonstration on Union Square in New York City Zionism & Birth of Modern Israel in 1948: Former Soviet Citizen Pays Tribute to Ben-Gurion ...

Click go fears of converting print files
Is there a way to convert a print queue item to a .RTF or .PDF file? I like to save or email them. - The Sydney Morning Herald

Sudanese woman ordered to hang under sharia law for converting to Christianity gives birth
Khartoum, Sudan: A Christian Sudanese woman sentenced to hang for apostasy has given birth in jail, a Western diplomat said on Tuesday.

Imams warn against radicalism to Aboriginal inmates converting to Islam
The prison system has enlisted the help of ASIO to crack down on radicalisation behind bars amid revelations that Aboriginals are converting ...

Converting the world's companies one by one - The Science Show - ABC Radio National (Australian Broadcasting ...
Image: Trucks carrying logs make their way up a road in Jambi, Indonesia. A vast area of the Sumatran forest, and orangutan habitat, is being ...

Converting Churches Into Homes Is The Latest Hollywood Trend
You don't have to be a believer to be moved by the beauty of a church.

Resources last updated: 12/15/2015 4:45:40 AM