Avatar billede axkris Nybegynder
30. maj 2004 - 11:24 Der er 2 kommentarer og
1 løsning

Multi array - Type mismatch

Hej

Jeg har ikke så meget erfaring med multi-arrays, så derfor får jeg en "Type mismatch" i bl.a. "arrPlusprofier(i)(0)".

Kan du hjælpe?

__________________________________________________________


        arrPlusprofier(i)(1) = rs("Trin")


    strSQL = "SELECT MAX(TRIN) AS MAX_TRIN FROM PLUSPROFIL_ANNONCE"
    set rs = dataConn.execute(strSQL)   
    strMaxTrin = RS("MAX_TRIN")
   
    strAnnonceIDs = ""   
       
    'skal optimeres senere
    dim arrPlusprofier(99)
    dim arrPlusprofierValgte(99)
           
    i = 0
       
    strQuery = "SELECT ANNONCE_ID, TRIN FROM PLUSPROFIL_ANNONCE WHERE POINTS < MAXPOINTS AND TRIN <> 0"
    set rs = dataConn.execute(strQuery)
    while not (rs.eof or rs.bof)
        arrPlusprofier(i)(0) = rs("Annonce_id")
        arrPlusprofier(i)(1) = rs("Trin")
        i = i + 1
    wend
               
    y = 0
    u = 0
    For y = LBound(arrPlusprofier) To UBound(arrPlusprofier) and u < 10
        randomize
        ranValue = int(i * rnd)
        randomize
        ranValue2 = int(strMaxTrin * rnd)
       
        if (arrPlusprofier(ranValue)(1)) > ranValue2 then
            arrPlusprofierValgte(u)(0) = arrPlusprofier(ranValue)(0)
            arrPlusprofierValgte(u)(1) = arrPlusprofier(ranValue)(1)
            u = u + 1
        end if

    next   
   
    if u > 1 then
        WriteTableStart "Plusprofiler", strHeadCellColor, "100%", "/grafik/layout/wavyb.gif"
        strSQL="SELECT * from PLUSPROFIL_ANNONCE WHERE " & right(strAnnonceIDs, len(strAnnonceIDs) - 4) & " ORDER BY TRIN DESC LIMIT 0,3"
        makePlusProfil strSQL, "true", "4", "true"
        WriteTableEnd
        makeSpace(5)
    end if
Avatar billede axkris Nybegynder
30. maj 2004 - 11:26 #1
Hov.. den første linie efter skildelinien - arrPlusprofier(i)(1) = rs("Trin") - skal du blot ignorer (det var en copy/past-fejl).
Avatar billede eagleeye Praktikant
30. maj 2004 - 12:09 #2
Du har kun angivet en dimention i definetionen af arrayet:

dim arrPlusprofier(99)

Prøv at give det to:

dim arrPlusprofier(3,99)
Avatar billede axkris Nybegynder
30. maj 2004 - 14:36 #3
Tak for hjælpen - nu virker det :-D

    strQuery = "SELECT COUNT(*) AS COUNT_RECORDS FROM PLUSPROFIL_ANNONCE WHERE POINTS < MAXPOINTS AND TRIN <> 0"
    set rs = dataConn.execute(strQuery)
    if not (rs.eof or rs.bof) then
        strCountRecords = round(rs("COUNT_RECORDS"))

        'skal optimeres senere
        redim arrPlusprofil(strCountRecords, 2)
           
        i = 0
       
        strQuery = "SELECT ANNONCE_ID, TRIN FROM PLUSPROFIL_ANNONCE WHERE POINTS < MAXPOINTS AND TRIN <> 0 ORDER BY TRIN DESC"
        set rs = dataConn.execute(strQuery)
        while not (rs.eof or rs.bof)
            arrPlusprofil(i,0) = rs("Annonce_id")
            arrPlusprofil(i,1) = rs("Trin")
            strTrinAll = int(strTrinAll) + int(rs("Trin"))
            rs.movenext
            i = i + 1
        wend
   
        strTrinMiddel = int(strTrinAll / strCountRecords)
               
        strAnnonceIDs = ""   

        u = 0
        p = 0
   
        For i = LBound(arrPlusprofil) To UBound(arrPlusprofil)
       
            'find tilfældig record
            randomize
            ranValue = int(strCountRecords * rnd)
       
            'find tilfældig værdi som dens trin skal overstige
            randomize
            ranValue2 = int(strTrinMiddel * rnd)
       
            if int(arrPlusprofil(ranValue, 1)) > int(ranValue2) then
                if inStr(strAnnonceIDs, arrPlusprofil(ranValue, 0)) = 0 then
                    strAnnonceIDs = strAnnonceIDs & " OR ANNONCE_ID = " & arrPlusprofil(ranValue, 0)
                    u = u + 1
                end if
            end if
            p = p + 1
       
            if u > 6 or p > (strCountRecords / 2) then
                exit for
            end if
        next   
   
        if u > 3 then
            WriteTableStart "Plusprofiler", strHeadCellColor, "100%", "/grafik/layout/wavyb.gif"
            strSQL="SELECT * from PLUSPROFIL_ANNONCE WHERE " & right(strAnnonceIDs, len(strAnnonceIDs) - 4) & " ORDER BY TRIN DESC LIMIT 0,3"
            makePlusProfil strSQL, "true", "4", "true"
            WriteTableEnd
            makeSpace(5)
        end if
    end if
Avatar billede Ny bruger Nybegynder

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.

Loading billede Opret Preview
Kategori
Kurser inden for grundlæggende programmering

Log ind eller opret profil

Hov!

For at kunne deltage på Computerworld Eksperten skal du være logget ind.

Det er heldigvis nemt at oprette en bruger: Det tager to minutter og du kan vælge at bruge enten e-mail, Facebook eller Google som login.

Du kan også logge ind via nedenstående tjenester

Seneste spørgsmål Seneste aktivitet
I går 10:21 Ny printer, men hvilken Af mort1 i Printere
13/0819:41 USB på Linux Af Uvanga i Linux
12/0818:26 Hvilken type mus Af mort1 i PC
11/0813:21 ms Forms Af leahcim i Andet software
10/0821:30 Blokeret på Snapchat? Af LineP i Chat & Messaging