'Program to find the string with the unique number of element. in the below example i have one array and i have eliminate the duplocate elemnet and generate the sting with unique elements
'Created by Zeeshan Khan
'-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
'Declare the array
dim a
'Assign the elements to the array which having 2 times 1
a= Array (1,2,3,1)
'Find the array Length
Arraylngth =ubound(a)
'Initialize the variable strfromArray with blank value
strfromArray=""
'Move the For loop for each index and get the value from array than concatenate these values and store in a one Variable
For i=0 to Arraylngth
strfromArray =strfromArray&a(i)
Next
'Below line of code is just to check what would be type of the variable
print TypeName (strfromArray)
Print "Concanated string from the array is now-->"&strfromArray
'Initialize the Counter
Counter=0
'nitialize the variable strUnique with blank value
strUnique =""
For j=1 to len(strfromArray)
If strcomp(mid(strfromArray,j,1),"1") = 0 Then
Temp = (mid(strfromArray,j,1))
counter =counter+1
If (counter>1) Then
strReplacedString=replace(strfromArray,mid(strfromArray,j,1),"")
Print "String after the replacing the repititive element is-->"&strReplacedString
End If
End If
Next
print "Final Unique string without any duplicate element is" &Temp&strReplacedStringere.
No comments:
Post a Comment