Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Conversion from string 'Kitchen 41' to type 'Double' is invalid.
..................................................................

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 in the code.

Exception Details: System.FormatException: Input string was not in a correct format.

Source Error:


Line 518: Dim location As Double = 0
Line 519: For t As Integer = 0 To Datagrid2.Items.Count - 1
Line 520: location += CDbl(Datagrid2.Items(t).Cells(0).Text)
Line 521: Next

What I have tried:

Hello everyone, what is the cause of this error? I am trying to show the location from the datagrid to the label
Posted

Look at the error message: it's pretty clear:
Error
Conversion from string 'Kitchen 41' to type 'Double' is invalid.
..................................................................

Input string was not in a correct format.
Location is a Double but at least one of the cells you are trying to convert contains the text "Kitchen 41" which is not a number at all.

Use the debugger to look at your DataGrid content and determine why you are trying to convert a non-numeric value. The most frequent reason is that it's the wrong column ... but we don't have access to your data so we can't tell exactly what you are trying to do.
 
Share this answer
 
Because this is the continuation from the other question (https://www.codeproject.com/Questions/5370000/I-want-a-solution-to-this-problem)
Perhaps you should show us per example what your DataGrid contains and what you want to add.

To continue the answer from OG :
What do you think is the sum of "Kitchen 41" and "Bathroom 12" in your opinion ?
 
Share this answer
 
Comments
OriginalGriff 16-Oct-23 1:45am    
"Bedroom 53"? :D
Ralf Meier 16-Oct-23 2:57am    
👍

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900