I have string value input=“027” and need to subtract 1 from this input string. So output should come as 026.
I tried assign activity like below but output will come as 26 not like as we expected.
output=(interger.parse(input)-1).tostring
Thanks in advance…
rlgandu
(Rajyalakshmi Gandu)
November 9, 2023, 6:58am
2
@Mahesh_Bandi1
input = “027”
(Int32.Parse(input) - 1).ToString(“D3”)
vrdabberu
(Varunraj Dabberu)
November 9, 2023, 6:58am
3
Hi @Mahesh_Bandi1 ’
use the below syntax
(Cint(Input)-1).ToString("D3")
Regards
mkankatala
(Mahesh Kankatala)
November 9, 2023, 6:59am
4
Hi @Mahesh_Bandi1
You can convert the string datatype to integer by using CInt Function.
- Assign -> Input = "027"
- Assign -> Output = CInt(Input)-1
Hope it helps!!
supriya117
(Supriya Allada)
November 9, 2023, 7:00am
5
Hi @Mahesh_Bandi1
input = "027"
output = (Integer.Parse(input) - 1).ToString("D3")
.ToString("D3") -->Converts the result back to a string and ensures it has three digits, adding leading zeros if necessary.
For more conversions, check this:
lrtetala
(Lakshman Reddy)
November 9, 2023, 7:01am
6
Hi @Mahesh_Bandi1
(Integer.Parse(Input) - 1).ToString("000")
neha.upase
(Neha Upase)
November 9, 2023, 7:02am
7
Hi,
You subtract 1 from a string like “027” using the method you’ve described, it first converts the string to an integer, subtracts 1, and then converts it back to a string. The conversion to an integer removes the leading zero, resulting in “26” instead of “026.”
you can use below expression:
(Int32.Parse(“027”) - 1).ToString(“D3”)
Anil_G
(Anil Gorthi)
November 9, 2023, 7:04am
8
@Mahesh_Bandi1
try this
output = If((Cint(input)-1).ToString.Count=2,"0","") + (Cint(input)-1).ToString
or use
Output = (Cint(input)-1).ToString.PadLeft(3, "0"c)
cheers
cheers
Mahesh_Bandi1:
I have string value input=“027” and need to subtract 1 from this input string. So output should come as 026.
I tried assign activity like below but output will come as 26 not like as we expected.
output=(interger.parse(input)-1).tostring
string input = "027";
int intValue = cint(input);
Thanks for your quick response but If I tired this way it is giving below error
rlgandu
(Rajyalakshmi Gandu)
November 9, 2023, 7:10am
11
@Mahesh_Bandi1
Can you try this
(Int32.Parse(input) - 1).ToString(“D3”)
Thanks @mkankatala
I tired this way already but it will give only 26 not as we expected.
vrdabberu
(Varunraj Dabberu)
November 9, 2023, 7:12am
13
Hi @Mahesh_Bandi1
Try this I have posted above
Regards
mkankatala
(Mahesh Kankatala)
November 9, 2023, 7:14am
14
Okay @Mahesh_Bandi1
For that use can try in this way
- Assign -> Input = "027"
- Assign -> output = (CInt(Input)-1).toString("D3")
In this we mentioned the number of items we have. It will give the result as 026
Hope you understand!!
Thanks @irtetala
I tried this way but it is giving completion error. PFA
lrtetala
(Lakshman Reddy)
November 9, 2023, 7:19am
16
@Mahesh_Bandi1
Please retype double quotes
1 Like
@Mahesh_Bandi1
assign
strr=“027”
Assign
strr1=(CInt(strr)-1).ToString(“D3”)
(CInt(strr)-1).ToString("D3")
cheer…!
WORKS FINALLY… Double quotes I retyped then it works …
I am very happy for all associate answers…Thanks a lot guys
1 Like
lrtetala
(Lakshman Reddy)
November 9, 2023, 7:26am
19
Please close this topic by marking the appropriate post as solution @Mahesh_Bandi1
Forum FAQ - How to mark a post as a solution
This document is part of our beginners guide .
This article will teach you how to properly mark a post as a solution.
We were closely following our last UiPath Forum feedback round! topic and carefully extracted all the bits of feedback that was provided. As such, we would like to tackle the topic of solutions on our Forum and how to properly use them.
When is the topic resolved?
The topic can be considered resolved when the topic author has fo…
Cheers!!
system
(system)
Closed
November 12, 2023, 7:26am
20
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.