Error: If: Input string was not in a correct format

(Convert.ToDecimal(row(5))>0.0) And (Not row(6).ToString.IsNumeric) And (row(8).ToString.Equals(builtDate.ToString))

The builtData variable holds a string value of a date formatted like yyyyMMdd.

I first added every condition in bracket thinking it was an error given because of the And Not given that it was written:

Convert.ToDecimal(row(5))>0.0 And Not row(6).ToString.IsNumeric And row(8).ToString.Equals(builtDate.ToString)

Also checked to see if the “>” condition wasn’t working given that I compared it to “0” instead of “0.0”

The data in row(5) can either be a year or a positive/negative decimal or integer.

The data in row(6) can either be a month written in numeric form or a string with a Name.

The data in row(8) is a date, type string written in the format yyyyMMdd.

Seems, the expression is confusing:

row(6).ToString.IsNumeric --> you are converting to string and checking if its number or not? what is the requirement here?

i guess this is causing the issue.
just put row(6).isNumeric and remove toString…

This should fix it i guess.
Let us know the results

found the issue where for some reason it is reading the first two rows that are used as the header

however I have an if statement to skip the first two rows. Also when reading in the csv file i have has header as fales given that I skip the first row. I’ve used this same if statement in my code so I’m lost as to why it doesn’t work the second time.


found the reason why the output was missing from my if statement @ArunVelaayudhanG thanks for the assistance.

1 Like