Braki
(Braki Meoni)
February 5, 2018, 3:30pm
1
Hi
I have to sum a variable of type “string” and another type “generic value” (which is the result of an ocr) and if I make the sum v1 + v2 with its original “type”, it does not do the sum, joins me together variables
i’m Try to convert the generic variable to Int32 but the next error appears.
Thanks for the help
Dominic
(Dominic)
February 5, 2018, 3:36pm
2
@Braki , the same topic was recently discussed in forum (for multiplication),
You can convert the string and generic value to integer and sum as follows,
Integer total = CInt(string value) + Cint(Generic
value)
Regards,
Dominic
1 Like
arivu96
(Arivazhagan A)
February 5, 2018, 3:51pm
3
Hi @Braki ,
Total= convert.ToInt32(BaseFinal)*Convert.ToInt32(Interest)
Change Generic value to string
Without convert to int also directly can use the generic value but some time if the value is empty/null it will through the error.
Always go to specific datatype for better performance.
Regards,
Arivu
Braki
(Braki Meoni)
February 5, 2018, 5:53pm
4
When I try to perform the conversion I get the following error message:
With the next code:
Integer total = CInt(string value) →
With the next code:
Total = Convert.ToInt32(Interest)
(error of the overload resolution because none of the functions (toint32) that are accessed is more specific for these arguments:
aksh1yadav
(AKSHAY YADAV)
February 6, 2018, 5:24am
6
Hey @Braki
Because you are passing Convert.ToInt32() a Generic data type variable.
Convert.ToInt32() - Converts the specified string representation of a number to an equivalent 32-bit signed integer.
So Use it like to avoid error in your workflow.
Int32 Total = convert.ToInt32(BaseFinal.ToString())*Convert.ToInt32(Interest.ToString())
Regards…!!
Aksh