I have a workflow that reads values of each cell in a table. If the value is greater than 1000 then it should give med a response “Too Large” else “ok”. However, it does not always work. For example the value in the table is 920 and it gives med “Too Large”
please change MaxValue variable type as Double and try.
hope my inputs are useful.
I tried changing the type to double, however i am getting an error :Option strict dissalows implicit conversion from String to Double
Change the datatype of rowValue to int or at the time of comparison do like this in if.
That was not working because you were comparing the string with int.
and you can use int for maxValue.
Thank you @aksh1yadav! That seems to do the trick. However, some of the cells might have blank values, not 0. And i am getting an error:
Anyway to fix this as well?
Try this: Cint(rowValue)> maxValue and Cint(rowValue)<>" "
Cint(rowValue)> maxValue and rowValue<>" "
Cint(rowValue)> maxValue and rowValue.Trim.length >0
Both will still throw on empty value. You need to do a shortcircuited check (
And) and reverse the condition:
Not String.IsNullOrWhitespace(rowValue) AndAlso CInt(rowValue)
Although I’d recommend spltting it to a nested if, so you can handle all 3 scenarios:
- Empty string.
- Too high value.
- OK value.
For me both are working mate @andrzej.kniola
They shouldn’t - CInt should throw on empty argument (as it did for @nbjerke) and that’s the first operation that’s done in that IF … That’s weird.
Don’t have time to check language reference deeper now, but
CInt(String.Empty) should throw an InvalidCastException every single time.
Yeah then better to use
Int32.TryParse(String.Empty,out op); // will return op=0 if you will pass an empty string
Int32.TryParse(“1234”,out op); //and will pass converted int value if you will pas a number string.
Int32.Parse(string, out int) method converts the specified string representation of 32-bit signed integer equivalent to out variable, and returns true if it is parsed successfully, false otherwise.
When string is a null reference, it will return 0 rather than throw ArgumentNullException. If string is other than an integer value, the out variable will have 0 rather than FormatException.
In Overflow Exception case also it will return only Zero.
Thanks for all the answers. So what would the syntax be for the Int32.TryParse(string, out int) be? Int32.TryParse(rowValue, out int) > maxValue?
I think you should insert Int32.TryParse method in Invoke Code Activity and pass two arguments: input string and output Int32 value. Try this example: example_out_int.xaml (5,1 KB)
Hi there @nbjerke,
The below example may assist in utilising the TryParse functionality.
TryParse Test.xaml (8.7 KB)
Thanks in advance,
Perfect! That did the trick! Thanks for all the help