OVH Cloud OVH Cloud

GoTo !!

10 réponses
Avatar
Jean-Michel
Bonjour, pour mon programme, j'utilise des goto vers des line1 : ou line 2:
Du coup, ca me met plein d'erreur du type End If sans le bloc If, alors que
j'ai bien le bon nombre!
Je crois que ca doit venir que du fait que quand le programme suit le goto,
et que je lui fait rentrer dans un bloc, et qu'il troude End If, ca doit le
gener, alors je voudrai savoir comment délimité le line1 par exemple, il est
existe un end line1 ???

Merci !

10 réponses

Avatar
François Picalausa
"Jean-Michel" a écrit dans le
message de news:%
pour mon programme, j'utilise des goto vers des line1 : ou
line 2: Du coup, ca me met plein d'erreur du type End If sans le bloc
If, alors que j'ai bien le bon nombre!
Je crois que ca doit venir que du fait que quand le programme suit le
goto, et que je lui fait rentrer dans un bloc, et qu'il troude End
If, ca doit le gener, alors je voudrai savoir comment délimité le
line1 par exemple, il est existe un end line1 ???



Bonjour/soir,

Le code suivant ne pose aucun problème:
Dim Toto As Long

Toto = 10
If Toto = 10 Then GoTo OtherIf
If Toto Then
Toto = -15
OtherIf:
MsgBox Toto
End If

Par contre, le goto est souvent source d'ennuis pour la relecture du code.

<quote src=msdn>
Note Too many GoTo statements can make code difficult to read and debug.
Use structured control statements (Do...Loop, For...Next, If...Then...Else,
Select Case) whenever possible.
</quote>

Si tu propose toi même de délimiter les morceau où tu vas employer goto,
utilise alors des méthodes et des fonctions!
Si il est impossible de faire autrement, poste le bout de code qui pose
problème et on tentera de trouver le problème!
--
François Picalausa (MVP VB)
FAQ VB : http://faq.vb.free.fr
MSDN : http://msdn.microsoft.com
Avatar
François Picalausa
"Jean-Michel" a écrit dans le
message de news:%
Mon code est un peu long mais bon, j'ai du mal a voir comment je
pourrai faire !
----------------

Private Sub cmdChute_Click()
Dim minimachine, lame, arasage, min, max, profiles, reste As
Double Dim LigneAEcrire As String
Dim Ptablo As Integer
Dim POFtablo As Integer
Dim cycle As String
Dim V As Integer
POFtablo = -1

minimachine = 100
lame = 3.7
arasage = 20
min = 400
max = 800
profiles = 6000

line1: Ptablo = 0
cycle = ""
If (Ptablo = UBound(tablo, 1)) Then
If (tablo(Ptablo).longueur <> 0) Then
reste = profiles - arasage - tablo(Ptablo).longueur -
lame Else
' on delimite et on passe à la longueur suivante
POFtablo = POFtablo + 1
ReDim Preserve OFtablo(POFtablo)
OFtablo(POFtablo).ref = tablo(Ptablo).ref ' -
OFtablo(POFtablo).dossier = tablo(Ptablo).dossier ' -
OFtablo(POFtablo).rep = tablo(Ptablo).rep ' -
OFtablo(POFtablo).mod = tablo(Ptablo).mod ' -
OFtablo(POFtablo).teinte = tablo(Ptablo).teinte ' -
OFtablo(POFtablo).qte = tablo(Ptablo).qte ' 0
OFtablo(POFtablo).longueur = tablo(Ptablo).longueur '
0 OFtablo(POFtablo).gauche = tablo(Ptablo).gauche ' -
OFtablo(POFtablo).cote = tablo(Ptablo).cote ' -
supprligne (Ptablo)
GoTo line1
End If

line2: If reste < 800 Then
MsgBox ("Attention, les longueurs sont trop grandes")
Else
' On agrandi le tableau OFtablo
POFtablo = POFtablo + 1
ReDim Preserve OFtablo(POFtablo)

' On retient pour l'OF
OFtablo(POFtablo).ref = tablo(Ptablo).ref
OFtablo(POFtablo).dossier = tablo(Ptablo).dossier
OFtablo(POFtablo).rep = tablo(Ptablo).rep
OFtablo(POFtablo).mod = tablo(Ptablo).mod
OFtablo(POFtablo).teinte = tablo(Ptablo).teinte
OFtablo(POFtablo).qte = tablo(Ptablo).qte
OFtablo(POFtablo).longueur = tablo(Ptablo).longueur
OFtablo(POFtablo).gauche = tablo(Ptablo).gauche
OFtablo(POFtablo).cote = tablo(Ptablo).cote
supprligne (Ptablo)

' On soustrait la longueur suivante en verifiant
l'existance de longueur suivante
line3: If (tablo(Ptablo).longueur > 0) Then
reste = reste - tablo(Ptablo).longueur - lame
Else
' ce cycle est terminer en avertissant d'utiliser
les chutes
cycle = "ta"
GoTo line7
End If

'point 1
Select Case reste
Case Is >= max ' reste est plus grand ou egale à
max(800) GoTo line2
Case (reste >= min And reste < max) ' reste > > min(400) mais < max(800)
line5: reste = reste + tablo(Ptablo).longueur + lame ' on
annule la derniere longueur
Ptablo = Ptablo + 1
GoTo line3
Case (reste >= minimachine And reste < min) ' reste > > (minimachine)100 mais < (min)400
' ce cycle est terminé
cycle = "t"
GoTo line6
Case Is < minimachine ' reste < (minimachine)100
reste = reste + tablo(Ptablo).longueur + lame ' on
annule la derniere longueur
reste = reste - lame - minimachine
Do
If (tablo(Ptablo).longueur = 0) Then
GoTo line4
End If
Ptablo = Ptablo + 1
Loop While (tablo(Ptablo).longueur > reste)

line4: If (tablo(Ptablo).longueur = 0) Then
' ce cycle est terminé en avertissant
d'utiliser les chutes
cycle = "ta"
GoTo line7
End If

reste = reste - tablo(Ptablo).longueur +
minimachine

'point 2
Select Case reste
Case Is >= max ' reste est plus grand ou egale à
max(800)
GoTo line2
Case (reste >= min And reste < max) ' reste > > min(400) mais < max(800)
GoTo line5
Case Is < min ' rest < min(400)
' ce cycle est terminé
cycle = "t"
GoTo line6
End Select

' ->ce cycle est terminer
line6: If (cycle = "t") Then

' On agrandi le tableau
POFtablo = POFtablo + 1
ReDim Preserve OFtablo(POFtablo)

' On retient pour l'OF
OFtablo(POFtablo).ref = tablo(Ptablo).ref
OFtablo(POFtablo).dossier > tablo(Ptablo).dossier OFtablo(POFtablo).rep > tablo(Ptablo).rep OFtablo(POFtablo).mod > tablo(Ptablo).mod OFtablo(POFtablo).teinte > tablo(Ptablo).teinte OFtablo(POFtablo).qte > tablo(Ptablo).qte OFtablo(POFtablo).longueur
= tablo(Ptablo).longueur
OFtablo(POFtablo).gauche > tablo(Ptablo).gauche OFtablo(POFtablo).cote > tablo(Ptablo).cote supprligne (Ptablo)

' On agrandi le tableau
POFtablo = POFtablo + 1
ReDim Preserve OFtablo(POFtablo)

OFtablo(POFtablo).ref = "-"
OFtablo(POFtablo).dossier = "-"
OFtablo(POFtablo).rep = "-"
OFtablo(POFtablo).mod = "-"
OFtablo(POFtablo).teinte = "-"
OFtablo(POFtablo).qte = "0"
OFtablo(POFtablo).longueur = "0"
OFtablo(POFtablo).gauche = "-"
OFtablo(POFtablo).cote = "-"
GoTo line1

End If
line7: If (cycle = "ta") Then

' On agrandi le tableau
POFtablo = POFtablo + 1
ReDim Preserve OFtablo(POFtablo)

' On retient pour l'OF
OFtablo(POFtablo).ref = tablo(Ptablo).ref
OFtablo(POFtablo).dossier > tablo(Ptablo).dossier OFtablo(POFtablo).rep > tablo(Ptablo).rep OFtablo(POFtablo).mod > tablo(Ptablo).mod OFtablo(POFtablo).teinte > tablo(Ptablo).teinte OFtablo(POFtablo).qte > tablo(Ptablo).qte OFtablo(POFtablo).longueur
= tablo(Ptablo).longueur
OFtablo(POFtablo).gauche > tablo(Ptablo).gauche OFtablo(POFtablo).cote > tablo(Ptablo).cote supprligne (Ptablo)

' On agrandi le tableau
POFtablo = POFtablo + 1
ReDim Preserve OFtablo(POFtablo)

OFtablo(POFtablo).ref = "-"
OFtablo(POFtablo).dossier = "-"
OFtablo(POFtablo).rep = "-"
OFtablo(POFtablo).mod = "-"
OFtablo(POFtablo).teinte = "-"
OFtablo(POFtablo).qte = "0"
OFtablo(POFtablo).longueur = "0"
OFtablo(POFtablo).gauche = "-"
OFtablo(POFtablo).cote = "-"
GoTo line1

End If
End If <<<<<<<<<<<<<<<<<<<<<<< C'est sur ce End If qui
pose probleme !!!
Else
lblFichier.Text = ""
For V = 0 To Ubount(OFtablo, 1)
lblFichier.Text = lblFichier & "|" &
OFtablo(POFtablo).ref lblFichier.Text = lblFichier &
"|" &
OFtablo(POFtablo).dossier
lblFichier.Text = lblFichier & "|" &
OFtablo(POFtablo).rep lblFichier.Text = lblFichier &
"|" & OFtablo(POFtablo).mod lblFichier.Text > lblFichier & "|" &
OFtablo(POFtablo).teinte
lblFichier.Text = lblFichier & "|" &
OFtablo(POFtablo).qte lblFichier.Text = lblFichier &
"|" &
OFtablo(POFtablo).longueur
lblFichier.Text = lblFichier & "|" &
OFtablo(POFtablo).gauche
lblFichier.Text = lblFichier & "|" &
OFtablo(POFtablo).cote & vbCrLf
Next V
End If
End Sub

------------------------------------

Si qqun trouve pk , ca serai cool :)
Merci !


"Jean-Michel" a écrit dans le
message news: #
Bonjour, pour mon programme, j'utilise des goto vers des line1 : ou
line 2: Du coup, ca me met plein d'erreur du type End If sans le
bloc If, alors que j'ai bien le bon nombre!
Je crois que ca doit venir que du fait que quand le programme suit
le goto, et que je lui fait rentrer dans un bloc, et qu'il troude
End If, ca doit le gener, alors je voudrai savoir comment délimité
le line1 par exemple, il est existe un end line1 ???

Merci !





Bonjour/soir,

En réindentant un peu ton code, voici ce que je lis:

If (Ptablo = UBound(tablo, 1)) Then
'point 1
Select Case reste
Case Is < minimachine
line7: If (cycle = "ta") Then
End If
End If <<<<<<<<<<<<<<<<<<<<<<< C'est sur ce End If qui pose
probleme !!!
Else
...
On a au même niveau Select Case et End If
Peut-être qu'un End Select serait plus approprié?

Il faudrait (mais je ne comprend pas bien ce code) faire diverse fonctions
et sub pour les tâches répétées, remplacer les goto en série par des do/loop
ou autre et ce serait alors, AMHA, plus lisible et ça éviterais (toujours
AMHA) ce genre d'erreurs.

--
François Picalausa (MVP VB)
FAQ VB : http://faq.vb.free.fr
MSDN : http://msdn.microsoft.com
Avatar
Jean-Michel
je vais essayer, merci !


"François Picalausa" a écrit dans le message news:

"Jean-Michel" a écrit dans le
message de news:%
> pour mon programme, j'utilise des goto vers des line1 : ou
> line 2: Du coup, ca me met plein d'erreur du type End If sans le bloc
> If, alors que j'ai bien le bon nombre!
> Je crois que ca doit venir que du fait que quand le programme suit le
> goto, et que je lui fait rentrer dans un bloc, et qu'il troude End
> If, ca doit le gener, alors je voudrai savoir comment délimité le
> line1 par exemple, il est existe un end line1 ???

Bonjour/soir,

Le code suivant ne pose aucun problème:
Dim Toto As Long

Toto = 10
If Toto = 10 Then GoTo OtherIf
If Toto Then
Toto = -15
OtherIf:
MsgBox Toto
End If

Par contre, le goto est souvent source d'ennuis pour la relecture du code.

<quote src=msdn>
Note Too many GoTo statements can make code difficult to read and debug.
Use structured control statements (Do...Loop, For...Next,


If...Then...Else,
Select Case) whenever possible.
</quote>

Si tu propose toi même de délimiter les morceau où tu vas employer goto,
utilise alors des méthodes et des fonctions!
Si il est impossible de faire autrement, poste le bout de code qui pose
problème et on tentera de trouver le problème!
--
François Picalausa (MVP VB)
FAQ VB : http://faq.vb.free.fr
MSDN : http://msdn.microsoft.com




Avatar
Jean-Michel
Mon code est un peu long mais bon, j'ai du mal a voir comment je pourrai
faire !
----------------

Private Sub cmdChute_Click()
Dim minimachine, lame, arasage, min, max, profiles, reste As Double
Dim LigneAEcrire As String
Dim Ptablo As Integer
Dim POFtablo As Integer
Dim cycle As String
Dim V As Integer
POFtablo = -1

minimachine = 100
lame = 3.7
arasage = 20
min = 400
max = 800
profiles = 6000

line1: Ptablo = 0
cycle = ""
If (Ptablo = UBound(tablo, 1)) Then
If (tablo(Ptablo).longueur <> 0) Then
reste = profiles - arasage - tablo(Ptablo).longueur - lame
Else
' on delimite et on passe à la longueur suivante
POFtablo = POFtablo + 1
ReDim Preserve OFtablo(POFtablo)
OFtablo(POFtablo).ref = tablo(Ptablo).ref ' -
OFtablo(POFtablo).dossier = tablo(Ptablo).dossier ' -
OFtablo(POFtablo).rep = tablo(Ptablo).rep ' -
OFtablo(POFtablo).mod = tablo(Ptablo).mod ' -
OFtablo(POFtablo).teinte = tablo(Ptablo).teinte ' -
OFtablo(POFtablo).qte = tablo(Ptablo).qte ' 0
OFtablo(POFtablo).longueur = tablo(Ptablo).longueur ' 0
OFtablo(POFtablo).gauche = tablo(Ptablo).gauche ' -
OFtablo(POFtablo).cote = tablo(Ptablo).cote ' -
supprligne (Ptablo)
GoTo line1
End If

line2: If reste < 800 Then
MsgBox ("Attention, les longueurs sont trop grandes")
Else
' On agrandi le tableau OFtablo
POFtablo = POFtablo + 1
ReDim Preserve OFtablo(POFtablo)

' On retient pour l'OF
OFtablo(POFtablo).ref = tablo(Ptablo).ref
OFtablo(POFtablo).dossier = tablo(Ptablo).dossier
OFtablo(POFtablo).rep = tablo(Ptablo).rep
OFtablo(POFtablo).mod = tablo(Ptablo).mod
OFtablo(POFtablo).teinte = tablo(Ptablo).teinte
OFtablo(POFtablo).qte = tablo(Ptablo).qte
OFtablo(POFtablo).longueur = tablo(Ptablo).longueur
OFtablo(POFtablo).gauche = tablo(Ptablo).gauche
OFtablo(POFtablo).cote = tablo(Ptablo).cote
supprligne (Ptablo)

' On soustrait la longueur suivante en verifiant l'existance
de longueur suivante
line3: If (tablo(Ptablo).longueur > 0) Then
reste = reste - tablo(Ptablo).longueur - lame
Else
' ce cycle est terminer en avertissant d'utiliser les
chutes
cycle = "ta"
GoTo line7
End If

'point 1
Select Case reste
Case Is >= max ' reste est plus grand ou egale à max(800)
GoTo line2
Case (reste >= min And reste < max) ' reste >= min(400) mais
< max(800)
line5: reste = reste + tablo(Ptablo).longueur + lame ' on
annule la derniere longueur
Ptablo = Ptablo + 1
GoTo line3
Case (reste >= minimachine And reste < min) ' reste > (minimachine)100 mais < (min)400
' ce cycle est terminé
cycle = "t"
GoTo line6
Case Is < minimachine ' reste < (minimachine)100
reste = reste + tablo(Ptablo).longueur + lame ' on
annule la derniere longueur
reste = reste - lame - minimachine
Do
If (tablo(Ptablo).longueur = 0) Then
GoTo line4
End If
Ptablo = Ptablo + 1
Loop While (tablo(Ptablo).longueur > reste)

line4: If (tablo(Ptablo).longueur = 0) Then
' ce cycle est terminé en avertissant d'utiliser les
chutes
cycle = "ta"
GoTo line7
End If

reste = reste - tablo(Ptablo).longueur + minimachine

'point 2
Select Case reste
Case Is >= max ' reste est plus grand ou egale à
max(800)
GoTo line2
Case (reste >= min And reste < max) ' reste >= min(400)
mais < max(800)
GoTo line5
Case Is < min ' rest < min(400)
' ce cycle est terminé
cycle = "t"
GoTo line6
End Select

' ->ce cycle est terminer
line6: If (cycle = "t") Then

' On agrandi le tableau
POFtablo = POFtablo + 1
ReDim Preserve OFtablo(POFtablo)

' On retient pour l'OF
OFtablo(POFtablo).ref = tablo(Ptablo).ref
OFtablo(POFtablo).dossier = tablo(Ptablo).dossier
OFtablo(POFtablo).rep = tablo(Ptablo).rep
OFtablo(POFtablo).mod = tablo(Ptablo).mod
OFtablo(POFtablo).teinte = tablo(Ptablo).teinte
OFtablo(POFtablo).qte = tablo(Ptablo).qte
OFtablo(POFtablo).longueur = tablo(Ptablo).longueur
OFtablo(POFtablo).gauche = tablo(Ptablo).gauche
OFtablo(POFtablo).cote = tablo(Ptablo).cote
supprligne (Ptablo)

' On agrandi le tableau
POFtablo = POFtablo + 1
ReDim Preserve OFtablo(POFtablo)

OFtablo(POFtablo).ref = "-"
OFtablo(POFtablo).dossier = "-"
OFtablo(POFtablo).rep = "-"
OFtablo(POFtablo).mod = "-"
OFtablo(POFtablo).teinte = "-"
OFtablo(POFtablo).qte = "0"
OFtablo(POFtablo).longueur = "0"
OFtablo(POFtablo).gauche = "-"
OFtablo(POFtablo).cote = "-"
GoTo line1

End If
line7: If (cycle = "ta") Then

' On agrandi le tableau
POFtablo = POFtablo + 1
ReDim Preserve OFtablo(POFtablo)

' On retient pour l'OF
OFtablo(POFtablo).ref = tablo(Ptablo).ref
OFtablo(POFtablo).dossier = tablo(Ptablo).dossier
OFtablo(POFtablo).rep = tablo(Ptablo).rep
OFtablo(POFtablo).mod = tablo(Ptablo).mod
OFtablo(POFtablo).teinte = tablo(Ptablo).teinte
OFtablo(POFtablo).qte = tablo(Ptablo).qte
OFtablo(POFtablo).longueur = tablo(Ptablo).longueur
OFtablo(POFtablo).gauche = tablo(Ptablo).gauche
OFtablo(POFtablo).cote = tablo(Ptablo).cote
supprligne (Ptablo)

' On agrandi le tableau
POFtablo = POFtablo + 1
ReDim Preserve OFtablo(POFtablo)

OFtablo(POFtablo).ref = "-"
OFtablo(POFtablo).dossier = "-"
OFtablo(POFtablo).rep = "-"
OFtablo(POFtablo).mod = "-"
OFtablo(POFtablo).teinte = "-"
OFtablo(POFtablo).qte = "0"
OFtablo(POFtablo).longueur = "0"
OFtablo(POFtablo).gauche = "-"
OFtablo(POFtablo).cote = "-"
GoTo line1

End If
End If <<<<<<<<<<<<<<<<<<<<<<< C'est sur ce End If qui pose
probleme !!!
Else
lblFichier.Text = ""
For V = 0 To Ubount(OFtablo, 1)
lblFichier.Text = lblFichier & "|" & OFtablo(POFtablo).ref
lblFichier.Text = lblFichier & "|" &
OFtablo(POFtablo).dossier
lblFichier.Text = lblFichier & "|" & OFtablo(POFtablo).rep
lblFichier.Text = lblFichier & "|" & OFtablo(POFtablo).mod
lblFichier.Text = lblFichier & "|" &
OFtablo(POFtablo).teinte
lblFichier.Text = lblFichier & "|" & OFtablo(POFtablo).qte
lblFichier.Text = lblFichier & "|" &
OFtablo(POFtablo).longueur
lblFichier.Text = lblFichier & "|" &
OFtablo(POFtablo).gauche
lblFichier.Text = lblFichier & "|" & OFtablo(POFtablo).cote
& vbCrLf
Next V
End If
End Sub

------------------------------------

Si qqun trouve pk , ca serai cool :)
Merci !


"Jean-Michel" a écrit dans le
message news: #
Bonjour, pour mon programme, j'utilise des goto vers des line1 : ou line


2:
Du coup, ca me met plein d'erreur du type End If sans le bloc If, alors


que
j'ai bien le bon nombre!
Je crois que ca doit venir que du fait que quand le programme suit le


goto,
et que je lui fait rentrer dans un bloc, et qu'il troude End If, ca doit


le
gener, alors je voudrai savoir comment délimité le line1 par exemple, il


est
existe un end line1 ???

Merci !




Avatar
Jean-Michel
Ca a l'air de se debloquer, merci !

"François Picalausa" a écrit dans le message news:

"Jean-Michel" a écrit dans le
message de news:%
> Mon code est un peu long mais bon, j'ai du mal a voir comment je
> pourrai faire !
> ----------------
>
> Private Sub cmdChute_Click()
> Dim minimachine, lame, arasage, min, max, profiles, reste As
> Double Dim LigneAEcrire As String
> Dim Ptablo As Integer
> Dim POFtablo As Integer
> Dim cycle As String
> Dim V As Integer
> POFtablo = -1
>
> minimachine = 100
> lame = 3.7
> arasage = 20
> min = 400
> max = 800
> profiles = 6000
>
> line1: Ptablo = 0
> cycle = ""
> If (Ptablo = UBound(tablo, 1)) Then
> If (tablo(Ptablo).longueur <> 0) Then
> reste = profiles - arasage - tablo(Ptablo).longueur -
> lame Else
> ' on delimite et on passe à la longueur suivante
> POFtablo = POFtablo + 1
> ReDim Preserve OFtablo(POFtablo)
> OFtablo(POFtablo).ref = tablo(Ptablo).ref ' -
> OFtablo(POFtablo).dossier = tablo(Ptablo).dossier ' -
> OFtablo(POFtablo).rep = tablo(Ptablo).rep ' -
> OFtablo(POFtablo).mod = tablo(Ptablo).mod ' -
> OFtablo(POFtablo).teinte = tablo(Ptablo).teinte ' -
> OFtablo(POFtablo).qte = tablo(Ptablo).qte ' 0
> OFtablo(POFtablo).longueur = tablo(Ptablo).longueur '
> 0 OFtablo(POFtablo).gauche = tablo(Ptablo).gauche ' -
> OFtablo(POFtablo).cote = tablo(Ptablo).cote ' -
> supprligne (Ptablo)
> GoTo line1
> End If
>
> line2: If reste < 800 Then
> MsgBox ("Attention, les longueurs sont trop grandes")
> Else
> ' On agrandi le tableau OFtablo
> POFtablo = POFtablo + 1
> ReDim Preserve OFtablo(POFtablo)
>
> ' On retient pour l'OF
> OFtablo(POFtablo).ref = tablo(Ptablo).ref
> OFtablo(POFtablo).dossier = tablo(Ptablo).dossier
> OFtablo(POFtablo).rep = tablo(Ptablo).rep
> OFtablo(POFtablo).mod = tablo(Ptablo).mod
> OFtablo(POFtablo).teinte = tablo(Ptablo).teinte
> OFtablo(POFtablo).qte = tablo(Ptablo).qte
> OFtablo(POFtablo).longueur = tablo(Ptablo).longueur
> OFtablo(POFtablo).gauche = tablo(Ptablo).gauche
> OFtablo(POFtablo).cote = tablo(Ptablo).cote
> supprligne (Ptablo)
>
> ' On soustrait la longueur suivante en verifiant
> l'existance de longueur suivante
> line3: If (tablo(Ptablo).longueur > 0) Then
> reste = reste - tablo(Ptablo).longueur - lame
> Else
> ' ce cycle est terminer en avertissant d'utiliser
> les chutes
> cycle = "ta"
> GoTo line7
> End If
>
> 'point 1
> Select Case reste
> Case Is >= max ' reste est plus grand ou egale à
> max(800) GoTo line2
> Case (reste >= min And reste < max) ' reste > > > min(400) mais < max(800)
> line5: reste = reste + tablo(Ptablo).longueur + lame ' on
> annule la derniere longueur
> Ptablo = Ptablo + 1
> GoTo line3
> Case (reste >= minimachine And reste < min) ' reste > > > (minimachine)100 mais < (min)400
> ' ce cycle est terminé
> cycle = "t"
> GoTo line6
> Case Is < minimachine ' reste < (minimachine)100
> reste = reste + tablo(Ptablo).longueur + lame ' on
> annule la derniere longueur
> reste = reste - lame - minimachine
> Do
> If (tablo(Ptablo).longueur = 0) Then
> GoTo line4
> End If
> Ptablo = Ptablo + 1
> Loop While (tablo(Ptablo).longueur > reste)
>
> line4: If (tablo(Ptablo).longueur = 0) Then
> ' ce cycle est terminé en avertissant
> d'utiliser les chutes
> cycle = "ta"
> GoTo line7
> End If
>
> reste = reste - tablo(Ptablo).longueur +
> minimachine
>
> 'point 2
> Select Case reste
> Case Is >= max ' reste est plus grand ou egale à
> max(800)
> GoTo line2
> Case (reste >= min And reste < max) ' reste > > > min(400) mais < max(800)
> GoTo line5
> Case Is < min ' rest < min(400)
> ' ce cycle est terminé
> cycle = "t"
> GoTo line6
> End Select
>
> ' ->ce cycle est terminer
> line6: If (cycle = "t") Then
>
> ' On agrandi le tableau
> POFtablo = POFtablo + 1
> ReDim Preserve OFtablo(POFtablo)
>
> ' On retient pour l'OF
> OFtablo(POFtablo).ref = tablo(Ptablo).ref
> OFtablo(POFtablo).dossier > > tablo(Ptablo).dossier OFtablo(POFtablo).rep > > tablo(Ptablo).rep OFtablo(POFtablo).mod > > tablo(Ptablo).mod OFtablo(POFtablo).teinte > > tablo(Ptablo).teinte OFtablo(POFtablo).qte > > tablo(Ptablo).qte OFtablo(POFtablo).longueur
> = tablo(Ptablo).longueur
> OFtablo(POFtablo).gauche > > tablo(Ptablo).gauche OFtablo(POFtablo).cote > > tablo(Ptablo).cote supprligne (Ptablo)
>
> ' On agrandi le tableau
> POFtablo = POFtablo + 1
> ReDim Preserve OFtablo(POFtablo)
>
> OFtablo(POFtablo).ref = "-"
> OFtablo(POFtablo).dossier = "-"
> OFtablo(POFtablo).rep = "-"
> OFtablo(POFtablo).mod = "-"
> OFtablo(POFtablo).teinte = "-"
> OFtablo(POFtablo).qte = "0"
> OFtablo(POFtablo).longueur = "0"
> OFtablo(POFtablo).gauche = "-"
> OFtablo(POFtablo).cote = "-"
> GoTo line1
>
> End If
> line7: If (cycle = "ta") Then
>
> ' On agrandi le tableau
> POFtablo = POFtablo + 1
> ReDim Preserve OFtablo(POFtablo)
>
> ' On retient pour l'OF
> OFtablo(POFtablo).ref = tablo(Ptablo).ref
> OFtablo(POFtablo).dossier > > tablo(Ptablo).dossier OFtablo(POFtablo).rep > > tablo(Ptablo).rep OFtablo(POFtablo).mod > > tablo(Ptablo).mod OFtablo(POFtablo).teinte > > tablo(Ptablo).teinte OFtablo(POFtablo).qte > > tablo(Ptablo).qte OFtablo(POFtablo).longueur
> = tablo(Ptablo).longueur
> OFtablo(POFtablo).gauche > > tablo(Ptablo).gauche OFtablo(POFtablo).cote > > tablo(Ptablo).cote supprligne (Ptablo)
>
> ' On agrandi le tableau
> POFtablo = POFtablo + 1
> ReDim Preserve OFtablo(POFtablo)
>
> OFtablo(POFtablo).ref = "-"
> OFtablo(POFtablo).dossier = "-"
> OFtablo(POFtablo).rep = "-"
> OFtablo(POFtablo).mod = "-"
> OFtablo(POFtablo).teinte = "-"
> OFtablo(POFtablo).qte = "0"
> OFtablo(POFtablo).longueur = "0"
> OFtablo(POFtablo).gauche = "-"
> OFtablo(POFtablo).cote = "-"
> GoTo line1
>
> End If
> End If <<<<<<<<<<<<<<<<<<<<<<< C'est sur ce End If qui
> pose probleme !!!
> Else
> lblFichier.Text = ""
> For V = 0 To Ubount(OFtablo, 1)
> lblFichier.Text = lblFichier & "|" &
> OFtablo(POFtablo).ref lblFichier.Text = lblFichier &
> "|" &
> OFtablo(POFtablo).dossier
> lblFichier.Text = lblFichier & "|" &
> OFtablo(POFtablo).rep lblFichier.Text = lblFichier &
> "|" & OFtablo(POFtablo).mod lblFichier.Text > > lblFichier & "|" &
> OFtablo(POFtablo).teinte
> lblFichier.Text = lblFichier & "|" &
> OFtablo(POFtablo).qte lblFichier.Text = lblFichier &
> "|" &
> OFtablo(POFtablo).longueur
> lblFichier.Text = lblFichier & "|" &
> OFtablo(POFtablo).gauche
> lblFichier.Text = lblFichier & "|" &
> OFtablo(POFtablo).cote & vbCrLf
> Next V
> End If
> End Sub
>
> ------------------------------------
>
> Si qqun trouve pk , ca serai cool :)
> Merci !
>
>
> "Jean-Michel" a écrit dans le
> message news: #
>> Bonjour, pour mon programme, j'utilise des goto vers des line1 : ou
>> line 2: Du coup, ca me met plein d'erreur du type End If sans le
>> bloc If, alors que j'ai bien le bon nombre!
>> Je crois que ca doit venir que du fait que quand le programme suit
>> le goto, et que je lui fait rentrer dans un bloc, et qu'il troude
>> End If, ca doit le gener, alors je voudrai savoir comment délimité
>> le line1 par exemple, il est existe un end line1 ???
>>
>> Merci !

Bonjour/soir,

En réindentant un peu ton code, voici ce que je lis:

If (Ptablo = UBound(tablo, 1)) Then
'point 1
Select Case reste
Case Is < minimachine
line7: If (cycle = "ta") Then
End If
End If <<<<<<<<<<<<<<<<<<<<<<< C'est sur ce End If qui


pose
probleme !!!
Else
...
On a au même niveau Select Case et End If
Peut-être qu'un End Select serait plus approprié?

Il faudrait (mais je ne comprend pas bien ce code) faire diverse fonctions
et sub pour les tâches répétées, remplacer les goto en série par des


do/loop
ou autre et ce serait alors, AMHA, plus lisible et ça éviterais (toujours
AMHA) ce genre d'erreurs.

--
François Picalausa (MVP VB)
FAQ VB : http://faq.vb.free.fr
MSDN : http://msdn.microsoft.com




Avatar
+The_Taco+
Ma mère ma toujours dit que les Goto, c'est le diable en personne :)

"Jean-Michel" a écrit dans le
message de news:%
Bonjour, pour mon programme, j'utilise des goto vers des line1 : ou line


2:
Du coup, ca me met plein d'erreur du type End If sans le bloc If, alors


que
j'ai bien le bon nombre!
Je crois que ca doit venir que du fait que quand le programme suit le


goto,
et que je lui fait rentrer dans un bloc, et qu'il troude End If, ca doit


le
gener, alors je voudrai savoir comment délimité le line1 par exemple, il


est
existe un end line1 ???

Merci !




Avatar
ng
Salut,
Petite remarque qui a son importance, j'ai pas lu tout ton code mais il
semble que tu crois que :

Dim minimachine, lame, arasage, min, max, profiles, reste As Double

va définir 'minimachine, lame, arasage, min, max, profiles' en Double or
c'est faux, seul 'reste' sera en Double, et le reste en Variant c'est juste?

Petit exemple qui le prouve :

Dim dNb1, dNb2 As Double
Dim dNb3 As Double, dNb4 As Double
Debug.Print VarType(dNb1)
Debug.Print VarType(dNb2)
Debug.Print VarType(dNb3)
Debug.Print VarType(dNb4)

Il faudra donc mettre des 'as double' pour chacune des variables !

Je te dis ca car ca va bcp jouer sur la rapidité de ton code et sur la place
mémoire occupée par tes variables..

Nicolas.

"Jean-Michel" a écrit dans le
message de news: O$
Ca a l'air de se debloquer, merci !

"François Picalausa" a écrit dans le message news:

> "Jean-Michel" a écrit dans le
> message de news:%
> > Mon code est un peu long mais bon, j'ai du mal a voir comment je
> > pourrai faire !
> > ----------------
> >
> > Private Sub cmdChute_Click()
> > Dim minimachine, lame, arasage, min, max, profiles, reste As
> > Double Dim LigneAEcrire As String
> > Dim Ptablo As Integer
> > Dim POFtablo As Integer
> > Dim cycle As String
> > Dim V As Integer
> > POFtablo = -1
> >
> > minimachine = 100
> > lame = 3.7
> > arasage = 20
> > min = 400
> > max = 800
> > profiles = 6000
> >
> > line1: Ptablo = 0
> > cycle = ""
> > If (Ptablo = UBound(tablo, 1)) Then
> > If (tablo(Ptablo).longueur <> 0) Then
> > reste = profiles - arasage - tablo(Ptablo).longueur -
> > lame Else
> > ' on delimite et on passe à la longueur suivante
> > POFtablo = POFtablo + 1
> > ReDim Preserve OFtablo(POFtablo)
> > OFtablo(POFtablo).ref = tablo(Ptablo).ref ' -
> > OFtablo(POFtablo).dossier = tablo(Ptablo).dossier ' -
> > OFtablo(POFtablo).rep = tablo(Ptablo).rep ' -
> > OFtablo(POFtablo).mod = tablo(Ptablo).mod ' -
> > OFtablo(POFtablo).teinte = tablo(Ptablo).teinte ' -
> > OFtablo(POFtablo).qte = tablo(Ptablo).qte ' 0
> > OFtablo(POFtablo).longueur = tablo(Ptablo).longueur '
> > 0 OFtablo(POFtablo).gauche = tablo(Ptablo).gauche ' -
> > OFtablo(POFtablo).cote = tablo(Ptablo).cote ' -
> > supprligne (Ptablo)
> > GoTo line1
> > End If
> >
> > line2: If reste < 800 Then
> > MsgBox ("Attention, les longueurs sont trop grandes")
> > Else
> > ' On agrandi le tableau OFtablo
> > POFtablo = POFtablo + 1
> > ReDim Preserve OFtablo(POFtablo)
> >
> > ' On retient pour l'OF
> > OFtablo(POFtablo).ref = tablo(Ptablo).ref
> > OFtablo(POFtablo).dossier = tablo(Ptablo).dossier
> > OFtablo(POFtablo).rep = tablo(Ptablo).rep
> > OFtablo(POFtablo).mod = tablo(Ptablo).mod
> > OFtablo(POFtablo).teinte = tablo(Ptablo).teinte
> > OFtablo(POFtablo).qte = tablo(Ptablo).qte
> > OFtablo(POFtablo).longueur = tablo(Ptablo).longueur
> > OFtablo(POFtablo).gauche = tablo(Ptablo).gauche
> > OFtablo(POFtablo).cote = tablo(Ptablo).cote
> > supprligne (Ptablo)
> >
> > ' On soustrait la longueur suivante en verifiant
> > l'existance de longueur suivante
> > line3: If (tablo(Ptablo).longueur > 0) Then
> > reste = reste - tablo(Ptablo).longueur - lame
> > Else
> > ' ce cycle est terminer en avertissant d'utiliser
> > les chutes
> > cycle = "ta"
> > GoTo line7
> > End If
> >
> > 'point 1
> > Select Case reste
> > Case Is >= max ' reste est plus grand ou egale à
> > max(800) GoTo line2
> > Case (reste >= min And reste < max) ' reste > > > > min(400) mais < max(800)
> > line5: reste = reste + tablo(Ptablo).longueur + lame ' on
> > annule la derniere longueur
> > Ptablo = Ptablo + 1
> > GoTo line3
> > Case (reste >= minimachine And reste < min) ' reste > > > > (minimachine)100 mais < (min)400
> > ' ce cycle est terminé
> > cycle = "t"
> > GoTo line6
> > Case Is < minimachine ' reste < (minimachine)100
> > reste = reste + tablo(Ptablo).longueur + lame ' on
> > annule la derniere longueur
> > reste = reste - lame - minimachine
> > Do
> > If (tablo(Ptablo).longueur = 0) Then
> > GoTo line4
> > End If
> > Ptablo = Ptablo + 1
> > Loop While (tablo(Ptablo).longueur > reste)
> >
> > line4: If (tablo(Ptablo).longueur = 0) Then
> > ' ce cycle est terminé en avertissant
> > d'utiliser les chutes
> > cycle = "ta"
> > GoTo line7
> > End If
> >
> > reste = reste - tablo(Ptablo).longueur +
> > minimachine
> >
> > 'point 2
> > Select Case reste
> > Case Is >= max ' reste est plus grand ou egale à
> > max(800)
> > GoTo line2
> > Case (reste >= min And reste < max) ' reste > > > > min(400) mais < max(800)
> > GoTo line5
> > Case Is < min ' rest < min(400)
> > ' ce cycle est terminé
> > cycle = "t"
> > GoTo line6
> > End Select
> >
> > ' ->ce cycle est terminer
> > line6: If (cycle = "t") Then
> >
> > ' On agrandi le tableau
> > POFtablo = POFtablo + 1
> > ReDim Preserve OFtablo(POFtablo)
> >
> > ' On retient pour l'OF
> > OFtablo(POFtablo).ref = tablo(Ptablo).ref
> > OFtablo(POFtablo).dossier > > > tablo(Ptablo).dossier OFtablo(POFtablo).rep > > > tablo(Ptablo).rep OFtablo(POFtablo).mod > > > tablo(Ptablo).mod OFtablo(POFtablo).teinte > > > tablo(Ptablo).teinte OFtablo(POFtablo).qte > > > tablo(Ptablo).qte OFtablo(POFtablo).longueur
> > = tablo(Ptablo).longueur
> > OFtablo(POFtablo).gauche > > > tablo(Ptablo).gauche OFtablo(POFtablo).cote > > > tablo(Ptablo).cote supprligne (Ptablo)
> >
> > ' On agrandi le tableau
> > POFtablo = POFtablo + 1
> > ReDim Preserve OFtablo(POFtablo)
> >
> > OFtablo(POFtablo).ref = "-"
> > OFtablo(POFtablo).dossier = "-"
> > OFtablo(POFtablo).rep = "-"
> > OFtablo(POFtablo).mod = "-"
> > OFtablo(POFtablo).teinte = "-"
> > OFtablo(POFtablo).qte = "0"
> > OFtablo(POFtablo).longueur = "0"
> > OFtablo(POFtablo).gauche = "-"
> > OFtablo(POFtablo).cote = "-"
> > GoTo line1
> >
> > End If
> > line7: If (cycle = "ta") Then
> >
> > ' On agrandi le tableau
> > POFtablo = POFtablo + 1
> > ReDim Preserve OFtablo(POFtablo)
> >
> > ' On retient pour l'OF
> > OFtablo(POFtablo).ref = tablo(Ptablo).ref
> > OFtablo(POFtablo).dossier > > > tablo(Ptablo).dossier OFtablo(POFtablo).rep > > > tablo(Ptablo).rep OFtablo(POFtablo).mod > > > tablo(Ptablo).mod OFtablo(POFtablo).teinte > > > tablo(Ptablo).teinte OFtablo(POFtablo).qte > > > tablo(Ptablo).qte OFtablo(POFtablo).longueur
> > = tablo(Ptablo).longueur
> > OFtablo(POFtablo).gauche > > > tablo(Ptablo).gauche OFtablo(POFtablo).cote > > > tablo(Ptablo).cote supprligne (Ptablo)
> >
> > ' On agrandi le tableau
> > POFtablo = POFtablo + 1
> > ReDim Preserve OFtablo(POFtablo)
> >
> > OFtablo(POFtablo).ref = "-"
> > OFtablo(POFtablo).dossier = "-"
> > OFtablo(POFtablo).rep = "-"
> > OFtablo(POFtablo).mod = "-"
> > OFtablo(POFtablo).teinte = "-"
> > OFtablo(POFtablo).qte = "0"
> > OFtablo(POFtablo).longueur = "0"
> > OFtablo(POFtablo).gauche = "-"
> > OFtablo(POFtablo).cote = "-"
> > GoTo line1
> >
> > End If
> > End If <<<<<<<<<<<<<<<<<<<<<<< C'est sur ce End If qui
> > pose probleme !!!
> > Else
> > lblFichier.Text = ""
> > For V = 0 To Ubount(OFtablo, 1)
> > lblFichier.Text = lblFichier & "|" &
> > OFtablo(POFtablo).ref lblFichier.Text = lblFichier &
> > "|" &
> > OFtablo(POFtablo).dossier
> > lblFichier.Text = lblFichier & "|" &
> > OFtablo(POFtablo).rep lblFichier.Text = lblFichier &
> > "|" & OFtablo(POFtablo).mod lblFichier.Text > > > lblFichier & "|" &
> > OFtablo(POFtablo).teinte
> > lblFichier.Text = lblFichier & "|" &
> > OFtablo(POFtablo).qte lblFichier.Text = lblFichier &
> > "|" &
> > OFtablo(POFtablo).longueur
> > lblFichier.Text = lblFichier & "|" &
> > OFtablo(POFtablo).gauche
> > lblFichier.Text = lblFichier & "|" &
> > OFtablo(POFtablo).cote & vbCrLf
> > Next V
> > End If
> > End Sub
> >
> > ------------------------------------
> >
> > Si qqun trouve pk , ca serai cool :)
> > Merci !
> >
> >
> > "Jean-Michel" a écrit dans le
> > message news: #
> >> Bonjour, pour mon programme, j'utilise des goto vers des line1 : ou
> >> line 2: Du coup, ca me met plein d'erreur du type End If sans le
> >> bloc If, alors que j'ai bien le bon nombre!
> >> Je crois que ca doit venir que du fait que quand le programme suit
> >> le goto, et que je lui fait rentrer dans un bloc, et qu'il troude
> >> End If, ca doit le gener, alors je voudrai savoir comment délimité
> >> le line1 par exemple, il est existe un end line1 ???
> >>
> >> Merci !
>
> Bonjour/soir,
>
> En réindentant un peu ton code, voici ce que je lis:
>
> If (Ptablo = UBound(tablo, 1)) Then
> 'point 1
> Select Case reste
> Case Is < minimachine
> line7: If (cycle = "ta") Then
> End If
> End If <<<<<<<<<<<<<<<<<<<<<<< C'est sur ce End If qui
pose
> probleme !!!
> Else
> ...
> On a au même niveau Select Case et End If
> Peut-être qu'un End Select serait plus approprié?
>
> Il faudrait (mais je ne comprend pas bien ce code) faire diverse


fonctions
> et sub pour les tâches répétées, remplacer les goto en série par des
do/loop
> ou autre et ce serait alors, AMHA, plus lisible et ça éviterais


(toujours
> AMHA) ce genre d'erreurs.
>
> --
> François Picalausa (MVP VB)
> FAQ VB : http://faq.vb.free.fr
> MSDN : http://msdn.microsoft.com
>
>




Avatar
+The_Taco+
Variant est une variable qui peut prendre n'importe quelle forme. Soit
string, integer, double... n'importe quoi dépendant quelle valeur tu lui
affectes. Voilà pourquoi les variables variant peuvent être dangereuse car
on a aucun contrôle sur elle..

Double est comme une variable de type Float (variable numérique à virgule)
mais plus grosse. Combien gros? Je ne sais pas exactement...

cheers



"Jean-Michel" a écrit dans le
message de news:
Merci pour ta reponse

Heu, quel est la difference en variant et double !

Merci d'avance


"ng" a écrit dans le message news:
#
> Salut,
> Petite remarque qui a son importance, j'ai pas lu tout ton code mais il
> semble que tu crois que :
>
> Dim minimachine, lame, arasage, min, max, profiles, reste As Double
>
> va définir 'minimachine, lame, arasage, min, max, profiles' en Double or
> c'est faux, seul 'reste' sera en Double, et le reste en Variant c'est
juste?
>
> Petit exemple qui le prouve :
>
> Dim dNb1, dNb2 As Double
> Dim dNb3 As Double, dNb4 As Double
> Debug.Print VarType(dNb1)
> Debug.Print VarType(dNb2)
> Debug.Print VarType(dNb3)
> Debug.Print VarType(dNb4)
>
> Il faudra donc mettre des 'as double' pour chacune des variables !
>
> Je te dis ca car ca va bcp jouer sur la rapidité de ton code et sur la
place
> mémoire occupée par tes variables..
>
> Nicolas.
>
> "Jean-Michel" a écrit dans le
> message de news: O$
> > Ca a l'air de se debloquer, merci !
> >
> > "François Picalausa" a écrit dans le message


news:
> >
> > > "Jean-Michel" a écrit dans


le
> > > message de news:%
> > > > Mon code est un peu long mais bon, j'ai du mal a voir comment je
> > > > pourrai faire !
> > > > ----------------
> > > >
> > > > Private Sub cmdChute_Click()
> > > > Dim minimachine, lame, arasage, min, max, profiles, reste As
> > > > Double Dim LigneAEcrire As String
> > > > Dim Ptablo As Integer
> > > > Dim POFtablo As Integer
> > > > Dim cycle As String
> > > > Dim V As Integer
> > > > POFtablo = -1
> > > >
> > > > minimachine = 100
> > > > lame = 3.7
> > > > arasage = 20
> > > > min = 400
> > > > max = 800
> > > > profiles = 6000
> > > >
> > > > line1: Ptablo = 0
> > > > cycle = ""
> > > > If (Ptablo = UBound(tablo, 1)) Then
> > > > If (tablo(Ptablo).longueur <> 0) Then
> > > > reste = profiles - arasage -
tablo(Ptablo).longueur -
> > > > lame Else
> > > > ' on delimite et on passe à la longueur suivante
> > > > POFtablo = POFtablo + 1
> > > > ReDim Preserve OFtablo(POFtablo)
> > > > OFtablo(POFtablo).ref = tablo(Ptablo).ref ' -
> > > > OFtablo(POFtablo).dossier = tablo(Ptablo).dossier
' -
> > > > OFtablo(POFtablo).rep = tablo(Ptablo).rep ' -
> > > > OFtablo(POFtablo).mod = tablo(Ptablo).mod ' -
> > > > OFtablo(POFtablo).teinte = tablo(Ptablo).teinte


' -
> > > > OFtablo(POFtablo).qte = tablo(Ptablo).qte ' 0
> > > > OFtablo(POFtablo).longueur tablo(Ptablo).longueur
'
> > > > 0 OFtablo(POFtablo).gauche = tablo(Ptablo).gauche
' -
> > > > OFtablo(POFtablo).cote = tablo(Ptablo).cote ' -
> > > > supprligne (Ptablo)
> > > > GoTo line1
> > > > End If
> > > >
> > > > line2: If reste < 800 Then
> > > > MsgBox ("Attention, les longueurs sont trop
grandes")
> > > > Else
> > > > ' On agrandi le tableau OFtablo
> > > > POFtablo = POFtablo + 1
> > > > ReDim Preserve OFtablo(POFtablo)
> > > >
> > > > ' On retient pour l'OF
> > > > OFtablo(POFtablo).ref = tablo(Ptablo).ref
> > > > OFtablo(POFtablo).dossier = tablo(Ptablo).dossier
> > > > OFtablo(POFtablo).rep = tablo(Ptablo).rep
> > > > OFtablo(POFtablo).mod = tablo(Ptablo).mod
> > > > OFtablo(POFtablo).teinte = tablo(Ptablo).teinte
> > > > OFtablo(POFtablo).qte = tablo(Ptablo).qte
> > > > OFtablo(POFtablo).longueur tablo(Ptablo).longueur
> > > > OFtablo(POFtablo).gauche = tablo(Ptablo).gauche
> > > > OFtablo(POFtablo).cote = tablo(Ptablo).cote
> > > > supprligne (Ptablo)
> > > >
> > > > ' On soustrait la longueur suivante en verifiant
> > > > l'existance de longueur suivante
> > > > line3: If (tablo(Ptablo).longueur > 0) Then
> > > > reste = reste - tablo(Ptablo).longueur - lame
> > > > Else
> > > > ' ce cycle est terminer en avertissant
d'utiliser
> > > > les chutes
> > > > cycle = "ta"
> > > > GoTo line7
> > > > End If
> > > >
> > > > 'point 1
> > > > Select Case reste
> > > > Case Is >= max ' reste est plus grand ou egale à
> > > > max(800) GoTo line2
> > > > Case (reste >= min And reste < max) ' reste > > > > > > min(400) mais < max(800)
> > > > line5: reste = reste + tablo(Ptablo).longueur + lame


'
on
> > > > annule la derniere longueur
> > > > Ptablo = Ptablo + 1
> > > > GoTo line3
> > > > Case (reste >= minimachine And reste < min) '


reste
> > > > > > (minimachine)100 mais < (min)400
> > > > ' ce cycle est terminé
> > > > cycle = "t"
> > > > GoTo line6
> > > > Case Is < minimachine ' reste < (minimachine)100
> > > > reste = reste + tablo(Ptablo).longueur + lame


'
on
> > > > annule la derniere longueur
> > > > reste = reste - lame - minimachine
> > > > Do
> > > > If (tablo(Ptablo).longueur = 0) Then
> > > > GoTo line4
> > > > End If
> > > > Ptablo = Ptablo + 1
> > > > Loop While (tablo(Ptablo).longueur > reste)
> > > >
> > > > line4: If (tablo(Ptablo).longueur = 0) Then
> > > > ' ce cycle est terminé en avertissant
> > > > d'utiliser les chutes
> > > > cycle = "ta"
> > > > GoTo line7
> > > > End If
> > > >
> > > > reste = reste - tablo(Ptablo).longueur +
> > > > minimachine
> > > >
> > > > 'point 2
> > > > Select Case reste
> > > > Case Is >= max ' reste est plus grand ou egale


à
> > > > max(800)
> > > > GoTo line2
> > > > Case (reste >= min And reste < max) ' reste > > > > > > min(400) mais < max(800)
> > > > GoTo line5
> > > > Case Is < min ' rest < min(400)
> > > > ' ce cycle est terminé
> > > > cycle = "t"
> > > > GoTo line6
> > > > End Select
> > > >
> > > > ' ->ce cycle est terminer
> > > > line6: If (cycle = "t") Then
> > > >
> > > > ' On agrandi le tableau
> > > > POFtablo = POFtablo + 1
> > > > ReDim Preserve OFtablo(POFtablo)
> > > >
> > > > ' On retient pour l'OF
> > > > OFtablo(POFtablo).ref = tablo(Ptablo).ref
> > > > OFtablo(POFtablo).dossier > > > > > tablo(Ptablo).dossier


OFtablo(POFtablo).rep
> > > > > tablo(Ptablo).rep OFtablo(POFtablo).mod > > > > > tablo(Ptablo).mod OFtablo(POFtablo).teinte


> > > > > tablo(Ptablo).teinte OFtablo(POFtablo).qte
> > > > > tablo(Ptablo).qte
OFtablo(POFtablo).longueur
> > > > = tablo(Ptablo).longueur
> > > > OFtablo(POFtablo).gauche > > > > > tablo(Ptablo).gauche


OFtablo(POFtablo).cote
> > > > > tablo(Ptablo).cote supprligne (Ptablo)
> > > >
> > > > ' On agrandi le tableau
> > > > POFtablo = POFtablo + 1
> > > > ReDim Preserve OFtablo(POFtablo)
> > > >
> > > > OFtablo(POFtablo).ref = "-"
> > > > OFtablo(POFtablo).dossier = "-"
> > > > OFtablo(POFtablo).rep = "-"
> > > > OFtablo(POFtablo).mod = "-"
> > > > OFtablo(POFtablo).teinte = "-"
> > > > OFtablo(POFtablo).qte = "0"
> > > > OFtablo(POFtablo).longueur = "0"
> > > > OFtablo(POFtablo).gauche = "-"
> > > > OFtablo(POFtablo).cote = "-"
> > > > GoTo line1
> > > >
> > > > End If
> > > > line7: If (cycle = "ta") Then
> > > >
> > > > ' On agrandi le tableau
> > > > POFtablo = POFtablo + 1
> > > > ReDim Preserve OFtablo(POFtablo)
> > > >
> > > > ' On retient pour l'OF
> > > > OFtablo(POFtablo).ref = tablo(Ptablo).ref
> > > > OFtablo(POFtablo).dossier > > > > > tablo(Ptablo).dossier


OFtablo(POFtablo).rep
> > > > > tablo(Ptablo).rep OFtablo(POFtablo).mod > > > > > tablo(Ptablo).mod OFtablo(POFtablo).teinte


> > > > > tablo(Ptablo).teinte OFtablo(POFtablo).qte
> > > > > tablo(Ptablo).qte
OFtablo(POFtablo).longueur
> > > > = tablo(Ptablo).longueur
> > > > OFtablo(POFtablo).gauche > > > > > tablo(Ptablo).gauche


OFtablo(POFtablo).cote
> > > > > tablo(Ptablo).cote supprligne (Ptablo)
> > > >
> > > > ' On agrandi le tableau
> > > > POFtablo = POFtablo + 1
> > > > ReDim Preserve OFtablo(POFtablo)
> > > >
> > > > OFtablo(POFtablo).ref = "-"
> > > > OFtablo(POFtablo).dossier = "-"
> > > > OFtablo(POFtablo).rep = "-"
> > > > OFtablo(POFtablo).mod = "-"
> > > > OFtablo(POFtablo).teinte = "-"
> > > > OFtablo(POFtablo).qte = "0"
> > > > OFtablo(POFtablo).longueur = "0"
> > > > OFtablo(POFtablo).gauche = "-"
> > > > OFtablo(POFtablo).cote = "-"
> > > > GoTo line1
> > > >
> > > > End If
> > > > End If <<<<<<<<<<<<<<<<<<<<<<< C'est sur ce End If qui
> > > > pose probleme !!!
> > > > Else
> > > > lblFichier.Text = ""
> > > > For V = 0 To Ubount(OFtablo, 1)
> > > > lblFichier.Text = lblFichier & "|" &
> > > > OFtablo(POFtablo).ref lblFichier.Text = lblFichier


&
> > > > "|" &
> > > > OFtablo(POFtablo).dossier
> > > > lblFichier.Text = lblFichier & "|" &
> > > > OFtablo(POFtablo).rep lblFichier.Text = lblFichier


&
> > > > "|" & OFtablo(POFtablo).mod lblFichier.Text > > > > > lblFichier & "|" &
> > > > OFtablo(POFtablo).teinte
> > > > lblFichier.Text = lblFichier & "|" &
> > > > OFtablo(POFtablo).qte lblFichier.Text = lblFichier


&
> > > > "|" &
> > > > OFtablo(POFtablo).longueur
> > > > lblFichier.Text = lblFichier & "|" &
> > > > OFtablo(POFtablo).gauche
> > > > lblFichier.Text = lblFichier & "|" &
> > > > OFtablo(POFtablo).cote & vbCrLf
> > > > Next V
> > > > End If
> > > > End Sub
> > > >
> > > > ------------------------------------
> > > >
> > > > Si qqun trouve pk , ca serai cool :)
> > > > Merci !
> > > >
> > > >
> > > > "Jean-Michel" a écrit dans
le
> > > > message news: #
> > > >> Bonjour, pour mon programme, j'utilise des goto vers des line1 :


ou
> > > >> line 2: Du coup, ca me met plein d'erreur du type End If sans le
> > > >> bloc If, alors que j'ai bien le bon nombre!
> > > >> Je crois que ca doit venir que du fait que quand le programme


suit
> > > >> le goto, et que je lui fait rentrer dans un bloc, et qu'il troude
> > > >> End If, ca doit le gener, alors je voudrai savoir comment


délimité
> > > >> le line1 par exemple, il est existe un end line1 ???
> > > >>
> > > >> Merci !
> > >
> > > Bonjour/soir,
> > >
> > > En réindentant un peu ton code, voici ce que je lis:
> > >
> > > If (Ptablo = UBound(tablo, 1)) Then
> > > 'point 1
> > > Select Case reste
> > > Case Is < minimachine
> > > line7: If (cycle = "ta") Then
> > > End If
> > > End If <<<<<<<<<<<<<<<<<<<<<<< C'est sur ce End If


qui
> > pose
> > > probleme !!!
> > > Else
> > > ...
> > > On a au même niveau Select Case et End If
> > > Peut-être qu'un End Select serait plus approprié?
> > >
> > > Il faudrait (mais je ne comprend pas bien ce code) faire diverse
> fonctions
> > > et sub pour les tâches répétées, remplacer les goto en série par des
> > do/loop
> > > ou autre et ce serait alors, AMHA, plus lisible et ça éviterais
> (toujours
> > > AMHA) ce genre d'erreurs.
> > >
> > > --
> > > François Picalausa (MVP VB)
> > > FAQ VB : http://faq.vb.free.fr
> > > MSDN : http://msdn.microsoft.com
> > >
> > >
> >
> >
>
>




Avatar
Jean-Michel
Merci pour ta reponse

Heu, quel est la difference en variant et double !

Merci d'avance


"ng" a écrit dans le message news:
#
Salut,
Petite remarque qui a son importance, j'ai pas lu tout ton code mais il
semble que tu crois que :

Dim minimachine, lame, arasage, min, max, profiles, reste As Double

va définir 'minimachine, lame, arasage, min, max, profiles' en Double or
c'est faux, seul 'reste' sera en Double, et le reste en Variant c'est


juste?

Petit exemple qui le prouve :

Dim dNb1, dNb2 As Double
Dim dNb3 As Double, dNb4 As Double
Debug.Print VarType(dNb1)
Debug.Print VarType(dNb2)
Debug.Print VarType(dNb3)
Debug.Print VarType(dNb4)

Il faudra donc mettre des 'as double' pour chacune des variables !

Je te dis ca car ca va bcp jouer sur la rapidité de ton code et sur la


place
mémoire occupée par tes variables..

Nicolas.

"Jean-Michel" a écrit dans le
message de news: O$
> Ca a l'air de se debloquer, merci !
>
> "François Picalausa" a écrit dans le message news:
>
> > "Jean-Michel" a écrit dans le
> > message de news:%
> > > Mon code est un peu long mais bon, j'ai du mal a voir comment je
> > > pourrai faire !
> > > ----------------
> > >
> > > Private Sub cmdChute_Click()
> > > Dim minimachine, lame, arasage, min, max, profiles, reste As
> > > Double Dim LigneAEcrire As String
> > > Dim Ptablo As Integer
> > > Dim POFtablo As Integer
> > > Dim cycle As String
> > > Dim V As Integer
> > > POFtablo = -1
> > >
> > > minimachine = 100
> > > lame = 3.7
> > > arasage = 20
> > > min = 400
> > > max = 800
> > > profiles = 6000
> > >
> > > line1: Ptablo = 0
> > > cycle = ""
> > > If (Ptablo = UBound(tablo, 1)) Then
> > > If (tablo(Ptablo).longueur <> 0) Then
> > > reste = profiles - arasage -


tablo(Ptablo).longueur -
> > > lame Else
> > > ' on delimite et on passe à la longueur suivante
> > > POFtablo = POFtablo + 1
> > > ReDim Preserve OFtablo(POFtablo)
> > > OFtablo(POFtablo).ref = tablo(Ptablo).ref ' -
> > > OFtablo(POFtablo).dossier = tablo(Ptablo).dossier


' -
> > > OFtablo(POFtablo).rep = tablo(Ptablo).rep ' -
> > > OFtablo(POFtablo).mod = tablo(Ptablo).mod ' -
> > > OFtablo(POFtablo).teinte = tablo(Ptablo).teinte ' -
> > > OFtablo(POFtablo).qte = tablo(Ptablo).qte ' 0
> > > OFtablo(POFtablo).longueur = tablo(Ptablo).longueur


'
> > > 0 OFtablo(POFtablo).gauche = tablo(Ptablo).gauche


' -
> > > OFtablo(POFtablo).cote = tablo(Ptablo).cote ' -
> > > supprligne (Ptablo)
> > > GoTo line1
> > > End If
> > >
> > > line2: If reste < 800 Then
> > > MsgBox ("Attention, les longueurs sont trop


grandes")
> > > Else
> > > ' On agrandi le tableau OFtablo
> > > POFtablo = POFtablo + 1
> > > ReDim Preserve OFtablo(POFtablo)
> > >
> > > ' On retient pour l'OF
> > > OFtablo(POFtablo).ref = tablo(Ptablo).ref
> > > OFtablo(POFtablo).dossier = tablo(Ptablo).dossier
> > > OFtablo(POFtablo).rep = tablo(Ptablo).rep
> > > OFtablo(POFtablo).mod = tablo(Ptablo).mod
> > > OFtablo(POFtablo).teinte = tablo(Ptablo).teinte
> > > OFtablo(POFtablo).qte = tablo(Ptablo).qte
> > > OFtablo(POFtablo).longueur = tablo(Ptablo).longueur
> > > OFtablo(POFtablo).gauche = tablo(Ptablo).gauche
> > > OFtablo(POFtablo).cote = tablo(Ptablo).cote
> > > supprligne (Ptablo)
> > >
> > > ' On soustrait la longueur suivante en verifiant
> > > l'existance de longueur suivante
> > > line3: If (tablo(Ptablo).longueur > 0) Then
> > > reste = reste - tablo(Ptablo).longueur - lame
> > > Else
> > > ' ce cycle est terminer en avertissant


d'utiliser
> > > les chutes
> > > cycle = "ta"
> > > GoTo line7
> > > End If
> > >
> > > 'point 1
> > > Select Case reste
> > > Case Is >= max ' reste est plus grand ou egale à
> > > max(800) GoTo line2
> > > Case (reste >= min And reste < max) ' reste > > > > > min(400) mais < max(800)
> > > line5: reste = reste + tablo(Ptablo).longueur + lame '


on
> > > annule la derniere longueur
> > > Ptablo = Ptablo + 1
> > > GoTo line3
> > > Case (reste >= minimachine And reste < min) ' reste
> > > > (minimachine)100 mais < (min)400
> > > ' ce cycle est terminé
> > > cycle = "t"
> > > GoTo line6
> > > Case Is < minimachine ' reste < (minimachine)100
> > > reste = reste + tablo(Ptablo).longueur + lame '


on
> > > annule la derniere longueur
> > > reste = reste - lame - minimachine
> > > Do
> > > If (tablo(Ptablo).longueur = 0) Then
> > > GoTo line4
> > > End If
> > > Ptablo = Ptablo + 1
> > > Loop While (tablo(Ptablo).longueur > reste)
> > >
> > > line4: If (tablo(Ptablo).longueur = 0) Then
> > > ' ce cycle est terminé en avertissant
> > > d'utiliser les chutes
> > > cycle = "ta"
> > > GoTo line7
> > > End If
> > >
> > > reste = reste - tablo(Ptablo).longueur +
> > > minimachine
> > >
> > > 'point 2
> > > Select Case reste
> > > Case Is >= max ' reste est plus grand ou egale à
> > > max(800)
> > > GoTo line2
> > > Case (reste >= min And reste < max) ' reste > > > > > min(400) mais < max(800)
> > > GoTo line5
> > > Case Is < min ' rest < min(400)
> > > ' ce cycle est terminé
> > > cycle = "t"
> > > GoTo line6
> > > End Select
> > >
> > > ' ->ce cycle est terminer
> > > line6: If (cycle = "t") Then
> > >
> > > ' On agrandi le tableau
> > > POFtablo = POFtablo + 1
> > > ReDim Preserve OFtablo(POFtablo)
> > >
> > > ' On retient pour l'OF
> > > OFtablo(POFtablo).ref = tablo(Ptablo).ref
> > > OFtablo(POFtablo).dossier > > > > tablo(Ptablo).dossier OFtablo(POFtablo).rep


> > > > tablo(Ptablo).rep OFtablo(POFtablo).mod > > > > tablo(Ptablo).mod OFtablo(POFtablo).teinte > > > > tablo(Ptablo).teinte OFtablo(POFtablo).qte > > > > tablo(Ptablo).qte OFtablo(POFtablo).longueur
> > > = tablo(Ptablo).longueur
> > > OFtablo(POFtablo).gauche > > > > tablo(Ptablo).gauche OFtablo(POFtablo).cote


> > > > tablo(Ptablo).cote supprligne (Ptablo)
> > >
> > > ' On agrandi le tableau
> > > POFtablo = POFtablo + 1
> > > ReDim Preserve OFtablo(POFtablo)
> > >
> > > OFtablo(POFtablo).ref = "-"
> > > OFtablo(POFtablo).dossier = "-"
> > > OFtablo(POFtablo).rep = "-"
> > > OFtablo(POFtablo).mod = "-"
> > > OFtablo(POFtablo).teinte = "-"
> > > OFtablo(POFtablo).qte = "0"
> > > OFtablo(POFtablo).longueur = "0"
> > > OFtablo(POFtablo).gauche = "-"
> > > OFtablo(POFtablo).cote = "-"
> > > GoTo line1
> > >
> > > End If
> > > line7: If (cycle = "ta") Then
> > >
> > > ' On agrandi le tableau
> > > POFtablo = POFtablo + 1
> > > ReDim Preserve OFtablo(POFtablo)
> > >
> > > ' On retient pour l'OF
> > > OFtablo(POFtablo).ref = tablo(Ptablo).ref
> > > OFtablo(POFtablo).dossier > > > > tablo(Ptablo).dossier OFtablo(POFtablo).rep


> > > > tablo(Ptablo).rep OFtablo(POFtablo).mod > > > > tablo(Ptablo).mod OFtablo(POFtablo).teinte > > > > tablo(Ptablo).teinte OFtablo(POFtablo).qte > > > > tablo(Ptablo).qte OFtablo(POFtablo).longueur
> > > = tablo(Ptablo).longueur
> > > OFtablo(POFtablo).gauche > > > > tablo(Ptablo).gauche OFtablo(POFtablo).cote


> > > > tablo(Ptablo).cote supprligne (Ptablo)
> > >
> > > ' On agrandi le tableau
> > > POFtablo = POFtablo + 1
> > > ReDim Preserve OFtablo(POFtablo)
> > >
> > > OFtablo(POFtablo).ref = "-"
> > > OFtablo(POFtablo).dossier = "-"
> > > OFtablo(POFtablo).rep = "-"
> > > OFtablo(POFtablo).mod = "-"
> > > OFtablo(POFtablo).teinte = "-"
> > > OFtablo(POFtablo).qte = "0"
> > > OFtablo(POFtablo).longueur = "0"
> > > OFtablo(POFtablo).gauche = "-"
> > > OFtablo(POFtablo).cote = "-"
> > > GoTo line1
> > >
> > > End If
> > > End If <<<<<<<<<<<<<<<<<<<<<<< C'est sur ce End If qui
> > > pose probleme !!!
> > > Else
> > > lblFichier.Text = ""
> > > For V = 0 To Ubount(OFtablo, 1)
> > > lblFichier.Text = lblFichier & "|" &
> > > OFtablo(POFtablo).ref lblFichier.Text = lblFichier &
> > > "|" &
> > > OFtablo(POFtablo).dossier
> > > lblFichier.Text = lblFichier & "|" &
> > > OFtablo(POFtablo).rep lblFichier.Text = lblFichier &
> > > "|" & OFtablo(POFtablo).mod lblFichier.Text > > > > lblFichier & "|" &
> > > OFtablo(POFtablo).teinte
> > > lblFichier.Text = lblFichier & "|" &
> > > OFtablo(POFtablo).qte lblFichier.Text = lblFichier &
> > > "|" &
> > > OFtablo(POFtablo).longueur
> > > lblFichier.Text = lblFichier & "|" &
> > > OFtablo(POFtablo).gauche
> > > lblFichier.Text = lblFichier & "|" &
> > > OFtablo(POFtablo).cote & vbCrLf
> > > Next V
> > > End If
> > > End Sub
> > >
> > > ------------------------------------
> > >
> > > Si qqun trouve pk , ca serai cool :)
> > > Merci !
> > >
> > >
> > > "Jean-Michel" a écrit dans


le
> > > message news: #
> > >> Bonjour, pour mon programme, j'utilise des goto vers des line1 : ou
> > >> line 2: Du coup, ca me met plein d'erreur du type End If sans le
> > >> bloc If, alors que j'ai bien le bon nombre!
> > >> Je crois que ca doit venir que du fait que quand le programme suit
> > >> le goto, et que je lui fait rentrer dans un bloc, et qu'il troude
> > >> End If, ca doit le gener, alors je voudrai savoir comment délimité
> > >> le line1 par exemple, il est existe un end line1 ???
> > >>
> > >> Merci !
> >
> > Bonjour/soir,
> >
> > En réindentant un peu ton code, voici ce que je lis:
> >
> > If (Ptablo = UBound(tablo, 1)) Then
> > 'point 1
> > Select Case reste
> > Case Is < minimachine
> > line7: If (cycle = "ta") Then
> > End If
> > End If <<<<<<<<<<<<<<<<<<<<<<< C'est sur ce End If qui
> pose
> > probleme !!!
> > Else
> > ...
> > On a au même niveau Select Case et End If
> > Peut-être qu'un End Select serait plus approprié?
> >
> > Il faudrait (mais je ne comprend pas bien ce code) faire diverse
fonctions
> > et sub pour les tâches répétées, remplacer les goto en série par des
> do/loop
> > ou autre et ce serait alors, AMHA, plus lisible et ça éviterais
(toujours
> > AMHA) ce genre d'erreurs.
> >
> > --
> > François Picalausa (MVP VB)
> > FAQ VB : http://faq.vb.free.fr
> > MSDN : http://msdn.microsoft.com
> >
> >
>
>




Avatar
Patrice Henrio
Il faut supprimer les Goto et les remplacer par d'autres lignes.
Si tu m'envoies ton bout de code je pense pouvoir te le retourner sans un
seul Goto et avec de la programmation plus lisible à l'aide de if then else,
while wend, repeat until, do loop.

"Jean-Michel" a écrit dans le
message de news:%
Bonjour, pour mon programme, j'utilise des goto vers des line1 : ou line


2:
Du coup, ca me met plein d'erreur du type End If sans le bloc If, alors


que
j'ai bien le bon nombre!
Je crois que ca doit venir que du fait que quand le programme suit le


goto,
et que je lui fait rentrer dans un bloc, et qu'il troude End If, ca doit


le
gener, alors je voudrai savoir comment délimité le line1 par exemple, il


est
existe un end line1 ???

Merci !