How to remove duplicates in integer

Hi Folks,

Request your help to remove duplicates from a integer.
Eg : 225336675992
output : 25367592

Thanks in advance.

1 Like

Hey @Vignesh96

Kindly try the below,

CInt(newString(int_Number.ToString.ToCharArray.Distinct))

Thanks
#nK

Int_var.Tostring.Distinct()

Or

Enumerable.Distinct(Int_Var.Tostring)

hi @Gangadhar_Athili bro

while using your both codes am getting the message “System.Linq.Enumerable+d__64`1[System.Char]”

@Nithinkrishna

bro am getting conversion error kinda error while using that code.

String.Join(“”,Enumerable.Distinct(Int_Var.Tostring).Select(Function(v) v.Tostring).Toarray)

Output :String (Convert this into Int32 by …CInt(Str_Output)

focusing to reduce the length of the statements

grafik
fist line is returning a string, second an int32

But as you see it is different to your requested output

with regex we can do following:

grafik

System.Text.RegularExpressions.Regex.Replace(225336675992.toString,"(\d)(\1?)", "$1")
 "25367592"

Converting the resulting string we can use CInt(YourStringVar) as shown above