uddenMedlem sedan mars 200174 inlägg hjärnstopp här nu.
har en array:
Dim groupShowArray(1)
arrayIndex = 0
sedan efter lite annat, så vill jag göra om storleken, om den är lika stor som variabeln arrayIndex, och gör följande:
intMax = UBound(groupShowArray)
If intMax = arrayIndex Then
Redim preserve groupShowArray(arrayIndex + 1)
End If
så får jag felmeddelandet
Microsoft VBScript runtime error '800a000a'
This array is fixed or temporarily locked
.. vad gör jag för fel?
hela koden sammanhängande:
Dim groupShowArray(1)
arrayIndex = 0 'startindex för array
itemCount = Session("ItemCount")
For i=0 To (itemCount - 1)
If tmpCart(5,i) <> "" Then
firstSplit = Split(tmpCart(5,i), "/////")
For j=0 To (UBound(firstSplit))
blnFound = False
tmpSplit = Split(firstSplit(j), "-")
For k=0 To arrayIndex
If groupShowArray(k) = tmpSplit(0) Then blnFound = True
Next 'k
If blnFound = False Then
'gör större array om det behövs
intMax = UBound(groupShowArray)
If intMax = arrayIndex Then
Redim preserve groupShowArray(arrayIndex + 1)
End If
End If
Next 'j
End If
Next 'i
nikoMedlem sedan juni 20022 599 inlägg LarsGMedlem sedan dec. 200012 464 inlägg Om du skall kunna använda redim så måste du göra
dim groupShowArray()
men jag förstår inte din kod. Du sätter arrayIndex = 0 och jämför det med ubound(groupShowArray). Med den deklaration du hade så blir ubound alltid 1 dvs aldrig lika med arrayIndex. Du sätter aldrig heller om värdet på arrayindex.
Med din skod så som den ser ut nu så skulle du aldrig komma till redim.
uddenMedlem sedan mars 200174 inlägg tack båda. glömt en del av array-hantering i ASP, visst måste jag använda redim, och inte skapa en fixed-size.
ang. koden LarsG så har du helt rätt, efter genomläsning såg jag att inklippningen inte blev komplett. Spelar ingen roll här, men så här är iaf koden som plockar ut grupptillhörighet för artiklar, ej dubbletter: (obs, ej rättad)
'skapar en array som ska fyllas med alla grupper som finns bland artiklarna
Dim groupShowArray(1)
arrayIndex = 0 'startindex för array
itemCount = Session("ItemCount")
'för varje unik artikel i korg
For i=0 To (itemCount - 1)
If tmpCart(5,i) <> "" Then
firstSplit = Split(tmpCart(5,i), "/////")
'för varje grupp som finns knuten till denna artikel
For j=0 To (UBound(firstSplit))
blnFound = False
tmpSplit = Split(firstSplit(j), "-")
'se om denna grupp finns i arrayen
For k=0 To arrayIndex
If groupShowArray(k) = tmpSplit(0) Then blnFound = True
Next 'k
If blnFound = False Then
'fanns ej, lägg till grupp i arrayen
'gör större array om det behövs
intMax = UBound(groupShowArray)
If intMax = arrayIndex Then
Redim preserve groupShowArray(arrayIndex + 1)
End If
'första ggn är plats 0 tom
If groupShowArray(arrayIndex) = "" Then
groupShowArray(arrayIndex) = tmpSplit(0)
Else
arrayIndex = arrayIndex + 1
groupShowArray(arrayIndex) = tmpSplit(0)
End If
End If
Next 'j
End If
Next 'i