IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

ASP Discussion :

Problème dans un tri de tableau


Sujet :

ASP

  1. #1
    Membre averti Avatar de pmboutteau
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Février 2005
    Messages
    601
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Santé

    Informations forums :
    Inscription : Février 2005
    Messages : 601
    Points : 420
    Points
    420
    Par défaut Problème dans un tri de tableau
    Voici mon code

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    'Organisation'
     
    Dim RecupOrganisation
    Dim rsCauseOrganisation
    Dim TabValeurOrganisation(1000)
    Dim TabCodeOrganisation(1000)
    Dim iOrganisation
    iOrganisation=0
     
    set rs = server.CreateObject("ADODB.RecordSet")
       rs.open RecupNum, cnBD
     
     
    do while not rs.eof
     
    RecupOrganisation="SELECT ArretCasing.CodeArret, Sum(ArretCasing.TpsArret) AS temps FROM ArretCasing WHERE ArretCasing.NumCommande='"&rs("NumCommande")&"'  AND DateDeSaisie=#"&englishDateDebut&"# AND ArretCasing.Poste='"&data1&"' AND ArretCasing.CodeArret='O1' AND (ArretCasing.NomPoste='HT4822' Or ArretCasing.NomPoste='HT4821' Or ArretCasing.NomPoste='ST4421' Or ArretCasing.NomPoste='ST4420') GROUP BY ArretCasing.CodeArret"
     
    	set rsCauseOrganisation = server.CreateObject("ADODB.RecordSet")
    	rsCauseOrganisation.open RecupOrganisation, cnBD
     
    	if not rsCauseOrganisation.eof Then
    		TabValeurOrganisation(iOrganisation)=rsCauseOrganisation("temps")
    	else
    		TabValeurOrganisation(iOrganisation)=0
    	End if
    	TabCodeOrganisation(iOrganisation)="O1"
    	iOrganisation=iOrganisation+1
     
    rsCauseOrganisation.close
    set rsCauseOrganisation = nothing
     
    RecupOrganisation="SELECT ArretCasing.CodeArret, Sum(ArretCasing.TpsArret) AS temps FROM ArretCasing WHERE ArretCasing.NumCommande='"&rs("NumCommande")&"'  AND DateDeSaisie=#"&englishDateDebut&"# AND ArretCasing.Poste='"&data1&"' AND ArretCasing.CodeArret='O2' AND (ArretCasing.NomPoste='HT4822' Or ArretCasing.NomPoste='HT4821' Or ArretCasing.NomPoste='ST4421' Or ArretCasing.NomPoste='ST4420') GROUP BY ArretCasing.CodeArret"
     
    	set rsCauseOrganisation = server.CreateObject("ADODB.RecordSet")
    	rsCauseOrganisation.open RecupOrganisation, cnBD
     
    	if not rsCauseOrganisation.eof Then
    		TabValeurOrganisation(iOrganisation)=rsCauseOrganisation("temps")
    	else
    		TabValeurOrganisation(iOrganisation)=0
    	End if
    	TabCodeOrganisation(iOrganisation)="O2"
    	iOrganisation=iOrganisation+1
     
    rsCauseOrganisation.close
    set rsCauseOrganisation = nothing
     
    RecupOrganisation="SELECT ArretCasing.CodeArret, Sum(ArretCasing.TpsArret) AS temps FROM ArretCasing WHERE ArretCasing.NumCommande='"&rs("NumCommande")&"'  AND DateDeSaisie=#"&englishDateDebut&"# AND ArretCasing.Poste='"&data1&"' AND ArretCasing.CodeArret='O4' AND (ArretCasing.NomPoste='HT4822' Or ArretCasing.NomPoste='HT4821' Or ArretCasing.NomPoste='ST4421' Or ArretCasing.NomPoste='ST4420') GROUP BY ArretCasing.CodeArret"
     
    	set rsCauseOrganisation = server.CreateObject("ADODB.RecordSet")
    	rsCauseOrganisation.open RecupOrganisation, cnBD
     
    	if not rsCauseOrganisation.eof Then
    		TabValeurOrganisation(iOrganisation)=rsCauseOrganisation("temps")
    	else
    		TabValeurOrganisation(iOrganisation)=0
    	End if
    	TabCodeOrganisation(iOrganisation)="O4"
    	iOrganisation=iOrganisation+1
     
    rsCauseOrganisation.close
    set rsCauseOrganisation = nothing
     
    RecupOrganisation="SELECT ArretCasing.CodeArret, Sum(ArretCasing.TpsArret) AS temps FROM ArretCasing WHERE ArretCasing.NumCommande='"&rs("NumCommande")&"'  AND DateDeSaisie=#"&englishDateDebut&"# AND ArretCasing.Poste='"&data1&"' AND ArretCasing.CodeArret='O5' AND (ArretCasing.NomPoste='HT4822' Or ArretCasing.NomPoste='HT4821' Or ArretCasing.NomPoste='ST4421' Or ArretCasing.NomPoste='ST4420') GROUP BY ArretCasing.CodeArret"
     
    	set rsCauseOrganisation = server.CreateObject("ADODB.RecordSet")
    	rsCauseOrganisation.open RecupOrganisation, cnBD
     
    	if not rsCauseOrganisation.eof Then
    		TabValeurOrganisation(iOrganisation)=rsCauseOrganisation("temps")
    	else
    		TabValeurOrganisation(iOrganisation)=0
    	End if
    	TabCodeOrganisation(iOrganisation)="O5"
    	iOrganisation=iOrganisation+1
     
    rsCauseOrganisation.close
    set rsCauseOrganisation = nothing
     
    RecupOrganisation="SELECT ArretCasing.CodeArret, Sum(ArretCasing.TpsArret) AS temps FROM ArretCasing WHERE ArretCasing.NumCommande='"&rs("NumCommande")&"'  AND DateDeSaisie=#"&englishDateDebut&"# AND ArretCasing.Poste='"&data1&"' AND ArretCasing.CodeArret='O6' AND (ArretCasing.NomPoste='HT4822' Or ArretCasing.NomPoste='HT4821' Or ArretCasing.NomPoste='ST4421' Or ArretCasing.NomPoste='ST4420') GROUP BY ArretCasing.CodeArret"
     
    	set rsCauseOrganisation = server.CreateObject("ADODB.RecordSet")
    	rsCauseOrganisation.open RecupOrganisation, cnBD
     
    	if not rsCauseOrganisation.eof Then
    		TabValeurOrganisation(iOrganisation)=rsCauseOrganisation("temps")
    	else
    		TabValeurOrganisation(iOrganisation)=0
    	End if
    	TabCodeOrganisation(iOrganisation)="O6"
    	iOrganisation=iOrganisation+1
     
    rsCauseOrganisation.close
    set rsCauseOrganisation = nothing
     
    rs.movenext
    loop
     
    rs.close
    set rs = nothing
     
    for j=1 To (iOrganisation-1)
    	x=TabValeurOrganisation(j)
    	y=TabCodeOrganisation(j)
    	k=j-1
    	do while (k>=0 And TabValeurOrganisation(k)>x)
    		TabValeurOrganisation(k+1)=TabValeurOrganisation(k)
    		TabCodeOrganisation(k+1)=TabCodeOrganisation(k)
    		k=k-1
    	loop
    	TabValeurOrganisation(k+1)=x
    	TabCodeOrganisation(k+1)=y
    Next

    Voici l'erreur
    Erreur d'exécution Microsoft VBScript (0x800A0009)
    Indice en dehors de la plage: 'k'

    Ce qui est bizarre c'est que je fais le même code exactement pour d'autres codes qui ont plus de causes que 5 et çà marche parfaitement!

    ours ours !! Au début elle est froide mais après elle est bonne!

  2. #2
    Expert éminent
    Avatar de Immobilis
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Mars 2004
    Messages
    6 559
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Mars 2004
    Messages : 6 559
    Points : 9 506
    Points
    9 506
    Par défaut
    Peux-tu nous faire une version allégée?
    Sinon, le message d'erreur est parfaitement explicite, non?
    C'est dedans que ça plante apparement.
    Peux-tu faire des response.write(UBOUND(de_tes_tableaux))?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    for j=1 To (iOrganisation-1) 
       x=TabValeurOrganisation(j) 
       y=TabCodeOrganisation(j) 
       k=j-1 
       do while (k>=0 And TabValeurOrganisation(k)>x) 
          TabValeurOrganisation(k+1)=TabValeurOrganisation(k) 
          TabCodeOrganisation(k+1)=TabCodeOrganisation(k) 
          k=k-1 
       loop 
       TabValeurOrganisation(k+1)=x 
       TabCodeOrganisation(k+1)=y 
    Next
    A+
    "Winter is coming" (ma nouvelle page d'accueil)

  3. #3
    Membre averti Avatar de pmboutteau
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Février 2005
    Messages
    601
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Santé

    Informations forums :
    Inscription : Février 2005
    Messages : 601
    Points : 420
    Points
    420
    Par défaut
    Voici donc le code

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
     
    for j=1 To (iChgtCom-1)
    	x=TabValeurChgtCom(j)
    	y=TabCodeChgtCom(j)
    	k=j-1
    	do while ((k>=0) And TabValeurChgtCom(k)>x)
    		TabValeurChgtCom(k+1)=TabValeurChgtCom(k)
    		TabCodeChgtCom(k+1)=TabCodeChgtCom(k)
    		k=k-1
    	loop
    	TabValeurChgtCom(k+1)=x
    	TabCodeChgtCom(k+1)=y
    Next
    Et l'erreur est:

    Erreur d'exécution Microsoft VBScript (0x800A0009)
    Indice en dehors de la plage: '-1'
    /PR/resultatJournalierTubing.asp, line 994

    Je vois pas pourquoi il ne sort pas de la boucle vu que je fais k>=0 ??

    et il ne fait pas çà à chaque fois
    ours ours !! Au début elle est froide mais après elle est bonne!

  4. #4
    Membre régulier
    Profil pro
    Inscrit en
    Octobre 2005
    Messages
    151
    Détails du profil
    Informations personnelles :
    Localisation : Belgique

    Informations forums :
    Inscription : Octobre 2005
    Messages : 151
    Points : 116
    Points
    116
    Par défaut
    et en mettant un OR plutôt que le AND dans ta condition ? Parce que là les deux doivent être réunies pour qu'il sorte du if donc même si tu as -1 mais que l'autre condition est encore bonne il continue...

  5. #5
    Membre averti Avatar de pmboutteau
    Homme Profil pro
    Ingénieur développement logiciels
    Inscrit en
    Février 2005
    Messages
    601
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France

    Informations professionnelles :
    Activité : Ingénieur développement logiciels
    Secteur : Santé

    Informations forums :
    Inscription : Février 2005
    Messages : 601
    Points : 420
    Points
    420
    Par défaut
    Non justement c'est le contraire. Avec le ANd les 2 conditions doivent être remplies. si une des 2 n'est pas remplie je sors de la boucle.
    ours ours !! Au début elle est froide mais après elle est bonne!

  6. #6
    Expert éminent
    Avatar de Immobilis
    Homme Profil pro
    Développeur .NET
    Inscrit en
    Mars 2004
    Messages
    6 559
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Bouches du Rhône (Provence Alpes Côte d'Azur)

    Informations professionnelles :
    Activité : Développeur .NET

    Informations forums :
    Inscription : Mars 2004
    Messages : 6 559
    Points : 9 506
    Points
    9 506
    Par défaut
    Fais un response.write de chacune de tes variables et des limites de tes tableaux pour voir leur progression au cours des boucles.
    "Winter is coming" (ma nouvelle page d'accueil)

Discussions similaires

  1. problème avec un tri de tableau et autre
    Par chupinours dans le forum Langage
    Réponses: 7
    Dernier message: 30/10/2012, 00h23
  2. problème de tri de tableau dans un programme
    Par chupinours dans le forum Débuter
    Réponses: 9
    Dernier message: 27/10/2012, 15h41
  3. Erreur array_multisort dans un tri de tableau
    Par GYK dans le forum Langage
    Réponses: 2
    Dernier message: 23/12/2011, 13h23
  4. Problème dans le tri de gridView
    Par sky88 dans le forum ASP.NET
    Réponses: 6
    Dernier message: 23/08/2011, 16h43
  5. [VBA-E] Problème de Version / tri de tableau.
    Par Gattuso dans le forum Macros et VBA Excel
    Réponses: 1
    Dernier message: 10/05/2007, 21h18

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo