Voilà, j'ai essayé de faire une petite boucle pour faire un test mais je
sèche devant le résultat ; voici ce que j'ai fait :
Sub test()
Dim S As String
S = "Toto"
For I = 1 To 4
S = S + S
Next I
MsgBox S
End Sub
Je pensais que la MsgBox allait m'afficher 4 fois " Toto " ; en fin de
compte, "toto" est affcihé 16 fois dans la MsgBox.
J'ai un peu de mal à comprendre mon erreur.....
Un très grand merci d'avance à ceux qui pourront m'éclairer...;-)
Merci et Joyeux Noêl à vous tous
Cordialement
--
Christophe
--------------------------------------------------------------
--------------------------------------------------------------
http://cerbe rmail.com/?cUkbZNnG8H (Enlever l'espace)
ou
http://viadresse.com?25031980
Recherche dans les Archives :
http://groups.google.fr/group/microsoft.public.fr.windowsxp?hl=fr
Forum Office :
http://forums.offices.free.fr/
Cette action est irreversible, confirmez la suppression du commentaire ?
Signaler le commentaire
Veuillez sélectionner un problème
Nudité
Violence
Harcèlement
Fraude
Vente illégale
Discours haineux
Terrorisme
Autre
Jacky
Bonsoir,
Pour comprendre ton erreur, insère un msgbox dans la boucle '--- Sub test() Dim S As String S = "Toto" For I = 1 To 4 S = S + S Msgbox S Next I MsgBox S End Sub '-------- Avent de commencer la boucle: S=toto 1er passage S=S+S donc S=TotoToto 2ème passage S=S+S et S est déjà égale à TotoToto Donc S=TotoTotoTotoToto 3ème passage S=S+S et S est déjà égale à TotoTotoTotoToto Donc S=TotoTotoTotoTotoTotoTotoTotoToto etc... '----------- La logique serait : '--------- Sub test() Dim X As String S = "Toto" For I = 1 To 4 X = X & S 'ou 'X = X + S 'ou 'X = X & "Toto" Next I MsgBox X End Sub
'-------- -- Salutations JJ
"Ayrton [ASC]" a écrit dans le message de news: %
Bonsoir à tous,
Voilà, j'ai essayé de faire une petite boucle pour faire un test mais je sèche devant le résultat ; voici ce que j'ai fait : Sub test() Dim S As String S = "Toto" For I = 1 To 4 S = S + S Next I MsgBox S End Sub
Je pensais que la MsgBox allait m'afficher 4 fois " Toto " ; en fin de compte, "toto" est affcihé 16 fois dans la MsgBox. J'ai un peu de mal à comprendre mon erreur..... Un très grand merci d'avance à ceux qui pourront m'éclairer...;-)
Merci et Joyeux Noêl à vous tous
Cordialement
-- Christophe -------------------------------------------------------------- -------------------------------------------------------------- http://cerbe rmail.com/?cUkbZNnG8H (Enlever l'espace) ou http://viadresse.com?25031980 Recherche dans les Archives : http://groups.google.fr/group/microsoft.public.fr.windowsxp?hl=fr Forum Office : http://forums.offices.free.fr/
Bonsoir,
Pour comprendre ton erreur, insère un msgbox dans la boucle
'---
Sub test()
Dim S As String
S = "Toto"
For I = 1 To 4
S = S + S
Msgbox S
Next I
MsgBox S
End Sub
'--------
Avent de commencer la boucle:
S=toto
1er passage S=S+S
donc S=TotoToto
2ème passage S=S+S et S est déjà égale à TotoToto
Donc S=TotoTotoTotoToto
3ème passage S=S+S et S est déjà égale à TotoTotoTotoToto
Donc S=TotoTotoTotoTotoTotoTotoTotoToto
etc...
'-----------
La logique serait :
'---------
Sub test()
Dim X As String
S = "Toto"
For I = 1 To 4
X = X & S
'ou
'X = X + S
'ou
'X = X & "Toto"
Next I
MsgBox X
End Sub
'--------
--
Salutations
JJ
"Ayrton [ASC]" <becoAS@plusdespam.fr> a écrit dans le message de news:
%23JaGaIvJHHA.1280@TK2MSFTNGP04.phx.gbl...
Bonsoir à tous,
Voilà, j'ai essayé de faire une petite boucle pour faire un test mais je
sèche devant le résultat ; voici ce que j'ai fait :
Sub test()
Dim S As String
S = "Toto"
For I = 1 To 4
S = S + S
Next I
MsgBox S
End Sub
Je pensais que la MsgBox allait m'afficher 4 fois " Toto " ; en fin de
compte, "toto" est affcihé 16 fois dans la MsgBox.
J'ai un peu de mal à comprendre mon erreur.....
Un très grand merci d'avance à ceux qui pourront m'éclairer...;-)
Merci et Joyeux Noêl à vous tous
Cordialement
--
Christophe
--------------------------------------------------------------
--------------------------------------------------------------
http://cerbe rmail.com/?cUkbZNnG8H (Enlever l'espace)
ou
http://viadresse.com?25031980
Recherche dans les Archives :
http://groups.google.fr/group/microsoft.public.fr.windowsxp?hl=fr
Forum Office :
http://forums.offices.free.fr/
Pour comprendre ton erreur, insère un msgbox dans la boucle '--- Sub test() Dim S As String S = "Toto" For I = 1 To 4 S = S + S Msgbox S Next I MsgBox S End Sub '-------- Avent de commencer la boucle: S=toto 1er passage S=S+S donc S=TotoToto 2ème passage S=S+S et S est déjà égale à TotoToto Donc S=TotoTotoTotoToto 3ème passage S=S+S et S est déjà égale à TotoTotoTotoToto Donc S=TotoTotoTotoTotoTotoTotoTotoToto etc... '----------- La logique serait : '--------- Sub test() Dim X As String S = "Toto" For I = 1 To 4 X = X & S 'ou 'X = X + S 'ou 'X = X & "Toto" Next I MsgBox X End Sub
'-------- -- Salutations JJ
"Ayrton [ASC]" a écrit dans le message de news: %
Bonsoir à tous,
Voilà, j'ai essayé de faire une petite boucle pour faire un test mais je sèche devant le résultat ; voici ce que j'ai fait : Sub test() Dim S As String S = "Toto" For I = 1 To 4 S = S + S Next I MsgBox S End Sub
Je pensais que la MsgBox allait m'afficher 4 fois " Toto " ; en fin de compte, "toto" est affcihé 16 fois dans la MsgBox. J'ai un peu de mal à comprendre mon erreur..... Un très grand merci d'avance à ceux qui pourront m'éclairer...;-)
Merci et Joyeux Noêl à vous tous
Cordialement
-- Christophe -------------------------------------------------------------- -------------------------------------------------------------- http://cerbe rmail.com/?cUkbZNnG8H (Enlever l'espace) ou http://viadresse.com?25031980 Recherche dans les Archives : http://groups.google.fr/group/microsoft.public.fr.windowsxp?hl=fr Forum Office : http://forums.offices.free.fr/
Ayrton [ASC]
Bonjour *Jacky*, Dans ton message de news:, Tu nous annonçais ce qui suit :-(*)
Bonsoir,
Bonjour,
[....}
'----------- La logique serait : '--------- Sub test() Dim X As String S = "Toto" For I = 1 To 4 X = X & S 'ou 'X = X + S 'ou 'X = X & "Toto" Next I MsgBox X End Sub
Effectivement, ça va mieux comme ça ;-) Je me suis bien emmêlé ! Ton explication est claire et je comprends maintenant mon erreur.
Encore merci
-- Christophe -------------------------------------------------------------- -------------------------------------------------------------- http://cerbe rmail.com/?cUkbZNnG8H (Enlever l'espace) ou http://viadresse.com?25031980 Recherche dans les Archives : http://groups.google.fr/group/microsoft.public.fr.windowsxp?hl=fr Forum Office : http://forums.offices.free.fr/
Bonjour *Jacky*,
Dans ton message de news:u5y3tcvJHHA.320@TK2MSFTNGP06.phx.gbl,
Tu nous annonçais ce qui suit :-(*)
Bonsoir,
Bonjour,
[....}
'-----------
La logique serait :
'---------
Sub test()
Dim X As String
S = "Toto"
For I = 1 To 4
X = X & S
'ou
'X = X + S
'ou
'X = X & "Toto"
Next I
MsgBox X
End Sub
Effectivement, ça va mieux comme ça ;-)
Je me suis bien emmêlé !
Ton explication est claire et je comprends maintenant mon erreur.
Encore merci
--
Christophe
--------------------------------------------------------------
--------------------------------------------------------------
http://cerbe rmail.com/?cUkbZNnG8H (Enlever l'espace)
ou
http://viadresse.com?25031980
Recherche dans les Archives :
http://groups.google.fr/group/microsoft.public.fr.windowsxp?hl=fr
Forum Office :
http://forums.offices.free.fr/
Bonjour *Jacky*, Dans ton message de news:, Tu nous annonçais ce qui suit :-(*)
Bonsoir,
Bonjour,
[....}
'----------- La logique serait : '--------- Sub test() Dim X As String S = "Toto" For I = 1 To 4 X = X & S 'ou 'X = X + S 'ou 'X = X & "Toto" Next I MsgBox X End Sub
Effectivement, ça va mieux comme ça ;-) Je me suis bien emmêlé ! Ton explication est claire et je comprends maintenant mon erreur.
Encore merci
-- Christophe -------------------------------------------------------------- -------------------------------------------------------------- http://cerbe rmail.com/?cUkbZNnG8H (Enlever l'espace) ou http://viadresse.com?25031980 Recherche dans les Archives : http://groups.google.fr/group/microsoft.public.fr.windowsxp?hl=fr Forum Office : http://forums.offices.free.fr/