Kruger wrote in dk.edb.internet.webdesign.serverside.asp:
> Hejsa. 
>  
> Jeg har en streng: 
>  
> "928,968,732,738,961,1078,1081,1068,1042,1014,1102,1053,1051,1055 
> ,1058,1051,928,1042,1155,1068" 
>  
> Jeg vil gerne lave strengen sådan at hvis der er 2 eller flere af 
> samme nummer kommer den til at hedde: 
>  
> "928_2,968_1,732_1,738_1,961_1,1078_1,1081_1,1068_2,1042_2,1014_1 
> ,1102_1,1053_1,1051_2,1055_1,1058_1,1155_1" 
>  
> Altså at hvert nummer bliver efterfulgt af hvor mange af nummeret 
> der forekommer. 
>  
> Nogle der har nogle gode forslag. 
>  
> Mvh Mads 
>  
Den her:
<%
strTal =
"928,968,732,738,961,1078,1081,1068,1042,1014,1102,1053,1051,1055,10
58,1051,928,1042,1155,1068"
arrTal = Split(strTal,",")
arrTal2 = Split(strTal,",")
For t = 0 to UBound(arrTal)
IntCount = 0
For n = 0 to UBound(arrTal)
If arrTal(t) = arrTal(n) Then
IntCount = IntCount + 1
End If
Next
arrTal2(t) = arrTal2(t) & "_" & IntCount
Next
strTal = ""
For t = LBound(arrTal2) to UBound(arrTal2)
If t = UBound(arrTal2) Then
strTal = strTal & arrTal2(t)
Else
strTal = strTal & arrTal2(t) & ","
End If
Next
Response.Write strTal
%>
Eller du kan lave en funktion (smart hvis du skal lave mange strenge
om):
<%
Function Count(strTal)
arrTal = Split(strTal,",")
arrTal2 = Split(strTal,",")
For t = 0 to UBound(arrTal)
IntCount = 0
For n = 0 to UBound(arrTal)
If arrTal(t) = arrTal(n) Then
IntCount = IntCount + 1
End If
Next
arrTal2(t) = arrTal2(t) & "_" & IntCount
Next
strTal = ""
For t = LBound(arrTal2) to UBound(arrTal2)
If t = UBound(arrTal2) Then
strTal = strTal & arrTal2(t)
Else
strTal = strTal & arrTal2(t) & ","
End If
Next
End Function
%>
<%
Tal =
"928,968,732,738,961,1078,1081,1068,1042,1014,1102,1053,1051,1055,10
58,1051,928,1042,1155,1068"
Response.Write Count(Tal)
Response.Write Tal
%>
- Check lige om der ikke er nogle linjeskift, som ikke burde være
der, der kommer når jeg sender dette indlæg.
-- 
Vil du lære at kode HTML, XHTML, CSS, SSI eller ASP?
 - Pædagogiske tutorials på dansk
 - Kom godt i gang med koderne
KLIK HER! => 
http://www.html.dk/tutorials