Questo è quello che ho raccolto
codice:
'---------------------------------------------------------------------------
'restituisce un vettore di valori duplicati nel vettore argomento
'---------------------------------------------------------------------------
Public Function ValoriDuplicati(ByVal v As String()) As String()
Dim u(v.GetUpperBound(0)) As String
Dim n As Integer = -1
For i As Integer = 0 To v.GetUpperBound(0)
For j As Integer = 0 To v.GetUpperBound(0)
If i <> j AndAlso v(i) = v(j) AndAlso Array.IndexOf(u, v(i)) = -1 Then
n += 1
u(n) = v(i)
Exit For
End If
Next
Next
ReDim Preserve u(n)
Return u
End Function
:quote: si, è in basic. L'ho messo perchè funziona. Da tradurre in javascript
Questo è sicuramente in javascript
codice:
function Button2_onclick()
{
var a = ['x','y','z','y','z','z'];
//var b = arrDoppi(a);
var c = ValoriDuplicati(a);
alert(c);
}
if (!Array.prototype.indexOf)
Array.prototype.indexOf = function(item, startIndex)
{
var len = this.length;
if (startIndex == null)
startIndex = 0;
else if (startIndex < 0)
{
startIndex += len;
if (startIndex < 0)
startIndex = 0;
}
for (var i = startIndex; i < len; i++)
{
var val = this[i] || this.charAt && this.charAt(i);
if (val == item)
return i;
}
return -1;
};
function ValoriDuplicati(v)
{
var u = [];
for(var i = 0; i < v.length; i++)
{
for(var j = 0; j < v.length; j++)
{
if(i != j && v[i] == v[j] && u.indexOf(v[i]) == -1)
{
u.push(v[i]);
break;
}
}
}
return u;
}
BADA CHE NON HO CONTROLLATO, E' ROBA VECCHIA