How to add two string values.
Ex: Num1=“23”
Num2=“34”
Sum=57
How to add two string values.
Ex: Num1=“23”
Num2=“34”
Sum=57
hi @Girish26,
Welcome to the community.
You can not perform arithmetic operations with string values directly. So if you want to add those two values, first you need to convert them into integers as below and add them.
string num1 = “23”
string num2 = “34”
string Sum = ( integer.Parse(num1) + integer.Parse(num2) ).ToString
Regards,
Tharusha
Hi,
Sum = (cint(Num1)+cint(Num2)).ToString
here the Sum is String Variable.
Hope this would be of help.
Regards,
Ashley Nihal Dcunha
Hi
It will be helpfull if you provide me a solution for this.
I have two string variable which contains time format
variable 1 =“11:00”
variable 2 = “4:00”
i need add this two variable so that my output time will be “15:00”
Try this:
String addTime = (timespan.parse(“11:00:00”)+timespan.parse(“4:00:00”)).Tostring
Thanks Tharusha!! I tried addition of Two String variables using UiPath. It worked properly. Thanks for Best Solution provided by you.
Regards
Rohit Lanjewar
Here, Start_Time and End_Time_Window variables should be string type. Have you declared it as string type or not ?
Show me what input you passed to those variables ?
Try to print the value of Start_Time and End_Time and see once.
If possible share your workflow. Will check and update you.
And also here You declared Variable name as “End_Time” but in the previous post you are using as “End_Time_Window”. Check it that also.
Hy I did little bit changes in my code and its working fine now…
Thank You
Hi,
i need to add “AA100275” +1.
does anyone have any suggestions?
thanks
add in what sense ? u want it as AA100276 or AA1002751?
if needed like AA1002751 then its straight forward “AA100275”+“1”
if needed like AA100276 then you have to split the string and then add 1 to the number part of it.
its done like this (insert this into the Message box activity)
System.Text.RegularExpressions.Regex.Matches(“AA100275”, “[A-z]+”)(0).ToString + (CInt(System.Text.RegularExpressions.Regex.Matches(“AA100275”, “\d+”)(0).ToString)+1).ToString
Thank you…it’s fine
Hi Tharusha
I have a doubt regarding the same
Sum=(CInt(FirstNum)+CInt(SecNum)).ToString
i could see the message box value as false instead of 30 for below workflow
Please refer the snippet to help me on the same
Welcome to the community If you want you can also create a new topic!
Sum=(CInt(FirstNum)+CInt(SecNum)).ToString
In this remove: Sum=
You will get the expected output!
Regards,
Ajay Mishra
This is an expression because you do not have Sum= inside double quotes. So what’s happening is it’s checking whether the value in the variable Sum = “30” and since it does not you get false.
If you want the message box to show Sum=30 then you have to do “Sum=” + (CInt(FirstNum)+CInt(SecNum)).ToString
we recommend to avoid log messages / write line / message boxes when the part implementation is to check. Instead we can work with debugging panels
when such a statement is needed (also could be shortened to the sum) we can do
for any further assistance just open a new topic and get individual help