How to check if integer value contains - sign using Uipath

Hi team, I have integer value.
Sometimes the int value have minus sign.

If integer value contains minus sign need to remove minus sign from the integer value.

Input : -23
Output: 23

Hi @Baby123

IntVariable = -23
  If
   IntVariable.ToString.Contains("-")
  Then
     IntVariable = Cint(IntVariable.ToSTring.Replace("-",""))
End If

Or else you can simply use:

Math.Abs(IntValue)

Regards

@Baby123

You can just use Math.abs(integervariable)

this always gives the positive value only

cheers

1 Like

Hi @Baby123

You can try these

If the input is string value just use any of the below methods

System.Text.RegularExpressions.Regex.Match(Input,"\d+").ToString
Input.Replace("-")

if the Input is integer datatype try this

Math.Abs(Input)

Regards
Sudharsan

Hi @Baby123

Try below

Math.Abs(-23)

Hope it will helps you :slight_smile:
Cheers!!

Hi @Baby123

- Assign -> Input = -23
- Assign -> Input = If(Input.toString.contains("-"),CInt(Input.toString.replace("-","")),Input)

Hope it helps!!

assign your interger variable = Math.Abs(yourIntegerValue)

→ Can use Math.Abs to get the absolute vlue of integer by removing -ve sign.
image

->Can use regex ,bu converting integer to string , remove any occurrence of the minus sign.
image

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.