Error with double

Hi,
I am doing the following assignment which is throwing a run time error. No syntax error shown.

dbl_result = dbl_value1 + Convert.ToDouble(datarow(“column1”).ToString)

Thank you,

Hi @A_Learner

Is the Column1 having an empty cell.

Regards

Thank you. It always has value.

Hi @A_Learner

Can you show an example of value in Column 1.

Regards

On the second thought, may be. Let me add a check to it and see. Thank you.

What’s the error message? You need to include information like this so we can help.

datarow is a datatype, you shouldn’t name a variable the same as a datatype.

The only details on the error is. Incorrect string format.

Thank you.

Try changing the name of the variable so it’s not the same as a datatype.

If that doesn’t work, use Debug to see what’s in the row’s column1 value.

It is time in hh:mm:ss format. I am trying to convert it into minutes and save in a double value. May be I am doing wrong way.

Hi @A_Learner

Can you try this syntax:

dbl_result = dbl_value1 +TimeSpan.Parse(datarow("column1").ToString).TotalMinutes

Regards

You can’t just convert hh:mm:ss to double because hh:mm:ss isn’t a number.

This is giving like 0.08123 etc.
Is there a way to get minutes like 6, 12 or 82 etc.

Thank you,

Hi @A_Learner

Can you give an example what is value in dbl_value1 and datarow("column1").ToString and you expected output.

dbl_result = dbl_value1 +TimeSpan.Parse(datarow("column1").ToString).TotalMinutes

I will check and modify the syntax for you.

Regards

datarow(column1).ToString is like 00:08:52 that is hh:mm:ss

and dbl_value1 is initially zero. It is in a loop, so whatever minutes value we calculate from TimeSpan.Parse(datarow(“column1”).ToString).TotalMinutes gets added to it.

Thank you,

Hi @A_Learner

Can you try this syntax:

dbl_result = dbl_value1 + Math.Round(TimeSpan.Parse(datarow("column1").ToString).TotalMinutes)

Regards

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.