If: Conversion from string "" to type 'Integer' is not valid

whats wrong with this condition:

CInt(row(“Vendor Invoice"+vblf+"Paid Amount”)) < CInt(row(“Total”))

i am getting this error : If: Conversion from string “” to type ‘Integer’ is not valid.

hi @sybasha

(“Vendor Invoice"+vblf+"Paid Amount”) is the column name?

Also I added the code to my UiPath and didn’t see the issue

image

Hi @sybasha,

why you use vblf inside row(“Vendor Invoice"+vblf+"Paid Amount”)?

Thankyou

hi @sybasha,

I guess Here we are trying to get a Row value with the Column Name (Vendor Invoice"+vblf+"Paid Amount)

  1. Here - Take a StringVariable Say ColumnName and
  2. assign it “Vendor Invoice"+vblf+“Paid Amount” - vblf should be a string variable here
  3. -Take a write line and print the value for ColumnName - If Correct column Name is displayed -

If vblf is type Integer - Then it should be used as vblf.tostring

CInt(row(“ColumnName”)) < CInt(row(“Total”))


Mukesh

2 Likes

vblf is for next line. in the same cell the column name is present in two lines

the vendor invoice paid amount contains null value also, thats why its giving the error:: [if: Conversion from string “” to type ‘Integer’ is not valid]

Makes sense…
But the (“”) Data needs to be the column name, so if you are trying to club in two columns try adding OR condition :slight_smile:

Hope this helps :smiley:

@sybasha You can check if the row value is Empty or having only Spaces using the below condition :
String.IsNullOrEmpty(row(“ColumnName”).ToString) or String.IsNullOrWhiteSpace(row(“ColumnName”).ToString)

2 Likes

@sybasha No. Only Empty Null values and Whitespaces. 0 is Still a value :sweat_smile:

1 Like

hi @sybasha

May you show the ScreenShot of Column name and the value within it you are trying to perform some operation…

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

@supermanPunch :

I am also trying to catch the empty/null and zero values with the following formula in the If condition:

string.IsNullOrWhiteSpace(row(“My_Excel_Column”).ToString) Or String.IsNullOrEmpty(row(“My_Excel_Column”).ToString) Or Cint(row(“My_Excel_Column”).ToString).Equals(0)

But, It captures only zero cell values and replace the value. The last command is running and ignoring the two conditions, i.e., IsNullOrWhiteSpace and IsNullOrEmpty.

Hi @Dr_Raza_Abidi_PhD ,

Based on the Operation that you are trying to perform, you would want to Check if a String Value is Empty. If not, then Check if it is 0, then do the appropriate operations.

But what I think we missed is that, if we do an “or” operation only even though the String Value is Found to be Empty, it would evaluate other Conditions.

For that purpose, I think it is better to use “orElse” instead of “or”, so that once a True condition is met, it doesn’t move and evaluate other Conditions.

Maybe in the Below way:

string.IsNullOrWhiteSpace(row(“My_Excel_Column”).ToString) OrElse Cint(row(“My_Excel_Column”).ToString).Equals(0)

The Operation String.IsNullOrEmpty could be removed as well, as the String.IsNullOrWhitespace would work fine for both.

Let us know if this doesn’t help with the problem that you are facing.

Great sir, great, Its working now but one more issue, pl see below:

Column 1 Output Column
0 Yes
7000000
1800000
5000000
1600000
0 Yes
Yes
100000
Yes
0 Yes
Yes
Yes
Yes
![image 365x337](upload://eQLRzkyZqqvHkI3hrTKKzzcnEhm.png)

Output column is exceeding with 3 more values.

Could you Please Explain what you mean by this Statement, as the Problem may not be of general type and we would need to look into the Details of “What is the Output that you are expecting with what may be the Supposed Inputs”.

Column 1 Column 2 Output Column
0 20000 20000
7000000 200000 200000
1800000 5000 5000
5000000 5000000
1600000 15000 15000
0 22000 22000
50000 50000
100000 50000 50000
20000 0 20000
100000 100000
![image 497x265](upload://log19Fb7pOZacv9ihQdGv6rTEBb.png)

Actually, For example, I wanted to copy the integer values from column 1 to the output column if column 2 found missing or zero values.

Hi @Dr_Raza_Abidi_PhD ,

To get a Better Idea and based on the Inputs and Ouputs that you have provided, I managed to make a Quick workflow which does the same. Find the workflow attached below.
Test_Process.xaml (8.9 KB)

Let me know if it is not the approach that you were looking.

Hi @supermanPunch : There is some activity missing in your script. Giving me an error that activity is missing. Pl. check. Thanks,

@Dr_Raza_Abidi_PhD , I believe when you Update the System.Activities and Excel Package to the latest one, the Missing activity error should be resolved

Okay thanks,