BOLETUS 2.0

cs_ghuysmans99 Messages postés 3982 Date d'inscription jeudi 14 juillet 2005 Statut Membre Dernière intervention 30 juin 2013 - 30 sept. 2011 à 17:54
jupevi Messages postés 3 Date d'inscription mardi 26 mai 2009 Statut Membre Dernière intervention 30 septembre 2011 - 30 sept. 2011 à 18:12
Cette discussion concerne un article du site. Pour la consulter dans son contexte d'origine, cliquez sur le lien ci-dessous.

https://codes-sources.commentcamarche.net/source/53636-boletus-2-0

jupevi Messages postés 3 Date d'inscription mardi 26 mai 2009 Statut Membre Dernière intervention 30 septembre 2011
30 sept. 2011 à 18:12
Merci Ghuymans99, c'est meilleure comme ça.
J'apprécie tous les conseils.
cs_ghuysmans99 Messages postés 3982 Date d'inscription jeudi 14 juillet 2005 Statut Membre Dernière intervention 30 juin 2013 16
30 sept. 2011 à 17:54
#For g = 1 To num#If Mid$(aser, g, 1) Mid$(NA, g, 1) Or Mid$(aser, g, 1) "*" Then
#L = L + 1
#''Else -->useless !
#''L = L
#End If

#If [...] Then
#[...]
#End
#''Else -->useless, put the 1st and the 2nd lines together
#''End If

#''If i = 0 Then GoTo 1 --> GOTO is really bad !
#If (Mid$(NA, num + 2, Len(NA) - num) = List1.List(i - 1)) And (i <> 0) Then
#''i = i -->useless !
#Else
#List1.AddItem Mid$(NA, num + 2, Len(NA) - (num - 1)), i
#i = i + 1
#End If
Let's use a simple formula : NOT(a AND b) = (NOT a) OR (NOT b)
So, NOT((Mid$(NA, num + 2, Len(NA) - num) = List1.List(i - 1)) And (i <> 0))
Becomes (Mid$(NA, num+2, Len(NA)-num) <> List1.List(i-1)) Or (i=0) ::
#If (Mid$(NA, num+2, Len(NA)-num) <> List1.List(i-1)) Or (i=0) Then
# List1.AddItem Mid$(NA, num + 2, Len(NA) - (num - 1)), i
# i = i + 1
#End If

Indenting your code is also a good idea : it'll be easier to read for others ...
Rejoignez-nous