11. marts 2004 - 10:23Der er
14 kommentarer og 1 løsning
Array position sammenlignes med andet array
Hovedproblemet er: En position i array [ResultatARR] skal sammenlignes med et andet array [arrS + et index nummer] . Hvis værdien stemmer overens skal placering i [arrS + et index nummer] registreres.
eksempler på data ResultatARR = "4,2,3,4,5,3,2,1,3,2,1,1" arrS0 = "2,3,1,4" arrS1 = "6,3,1,3" etc
Nedenstående fungerer fint som udgangspunkt - bortset fra at index nummer i arrS0(n) skal skifte syncront med i! Det vil sige, at position ResultatARR (0) skal sammenlignes med arrS0, at ResultatARR (1) skal sammenlignes med arrS1 osv.
Hvordan løses det?
For i = 0 to 11 var_resultat = ResultatARR (i)
For n = 0 to 3 If var_resultat = arrS0(n) then If n = 0 then resultat1 = resultat1 + 1 end if If n = 1 then resultat2 = resultat2 + 1 end if If n = 2 then resultat3 = resultat3 + 1 end if If n = 3 then resultat4 = resultat4 + 1 end if end if next next
For i = 0 to 11 var_resultat = ResultatARR (i) if i = 0 then arr = arrS0 elseif i = 1 then arr = arrS1 else arr = defaultarray 'ret selv til her... end if For n = 0 to 3 If var_resultat = arr(n) then If n = 0 then resultat1 = resultat1 + 1 end if If n = 1 then resultat2 = resultat2 + 1 end if If n = 2 then resultat3 = resultat3 + 1 end if If n = 3 then resultat4 = resultat4 + 1 end if end if next next
Noget i denne stil, hvor du smider værdien af dit array over i en ny variabel hvis der er tale om et andet nummer i i. Du kan selv skrive mere til på ifsætningen i toppen.
For i = 0 to 11 var_resultat = ResultatARR (i) if i = 0 then for j = 0 to UBound(arrS0) arr(j) = arrS0(j) next elseif i = 1 then for j = 0 to UBound(arrS0) arr(j) = arrS1(j) next else arr = defaultarray 'ret selv til her... end if For n = 0 to 3 If var_resultat = arr(n) then If n = 0 then resultat1 = resultat1 + 1 end if If n = 1 then resultat2 = resultat2 + 1 end if If n = 2 then resultat3 = resultat3 + 1 end if If n = 3 then resultat4 = resultat4 + 1 end if end if next next
Så prøv det her, hvor hvert element bliver kopieret et af gangen.
så laver vi det lidt om... gør sådan her i stedet.
For i = 0 to 11 var_resultat = ResultatARR (i) if i = 0 then myarr = split(s0,",") elseif i = 1 then myarr = split(s1,",") else arr = defaultarray 'ret selv til her... end if For n = 0 to 3 If var_resultat = myarr(n) then If n = 0 then resultat1 = resultat1 + 1 end if If n = 1 then resultat2 = resultat2 + 1 end if If n = 2 then resultat3 = resultat3 + 1 end if If n = 3 then resultat4 = resultat4 + 1 end if end if next next
Fejlen er fundet, som ikke har noget med dette script at gøre. Det fungerer perfekt nu.
:-)) k_l
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.