Attila54
Messages postés409Date d'inscriptionjeudi 30 juin 2005StatutMembreDernière intervention21 novembre 2013
-
17 nov. 2010 à 18:39
Attila54
Messages postés409Date d'inscriptionjeudi 30 juin 2005StatutMembreDernière intervention21 novembre 2013
-
19 nov. 2010 à 13:11
bonsoir,
dans un form, j'ai 6 Textbox et un bouton de calcul
je sais que mes formules de calcul sont bonnes, mais je pêche dans la présentation de mon code, à savoir :
j'ai volontairement occulté les val mais ils sont présents dans l'original
Textbox1.Text = une valeur entrée comprise entre -2.00 et +2.00
Textbox2.Text à textbox6.Text = des valeurs calculées
textbox3, 4 et 5 dépendent de textox1
- si Textbox1.text < 0 alors
Textbox2.Text = moncalcul1
Textbox3.Text = moncalcul2
Textbox4.Text = moncalcul3
- si Textbox1.text > 0 alors
Textbox2.Text = moncalcul4
Textbox3.Text = moncalcul5
Textbox4.Text = moncalcul6
Textbox6 dépend de textbox4 et textbox5
- si Textbox4.text < textbox5.text alors
Textbox6 = moncalcul7
- si Textbox4.text < textbox5.text alors
Textbox6 = moncalcul8
j'ai fait tout dabord un code bien français a savoir :
if Textbox1.text < 0 then
Textbox2.Text = moncalcul1
Textbox3.Text = moncalcul2
Textbox4.Text = moncalcul3
end If
if Textbox1.text > 0 then
Textbox2.Text = moncalcul4
Textbox3.Text = moncalcul5
Textbox4.Text = moncalcul6
end if
if Textbox4.text < textbox5.text then
Textbox6 = moncalcul7
end if
if Textbox5.text < textbox4.text alors
Textbox6 = moncalcul8
end if
end sub
j'ai ensuite voulu faire plus "propre" mais je m'emmêle les pinceaux avec mes "if", du coup, plus rien ne marche alors qu'auparavant je n'avais de problèmes qu'avec certaines valeurs
Serait il possible d'avoir une petite aide afin de rendre mon code plus propre ???
Merci par avance
raffika
Messages postés269Date d'inscriptiondimanche 31 mai 2009StatutMembreDernière intervention12 mars 2011 17 nov. 2010 à 19:05
Salut,
if Textbox1.text < 0 then
Textbox2.Text = moncalcul1
Textbox3.Text = moncalcul2
Textbox4.Text = moncalcul3
else
'end If
'if Textbox1.text > 0 then
Textbox2.Text = moncalcul4
Textbox3.Text = moncalcul5
Textbox4.Text = moncalcul6
end if
if Textbox4.text < textbox5.text then
Textbox6 = moncalcul7
else
'end if
'if Textbox5.text < textbox4.text alors
Textbox6 = moncalcul8
end if
end sub
Je ne vois pas plus propre ;)
Sinon si tu fais des calculs compliqués
tu peux utiliser des fonctions et des sub...
Bonsoir
cnt
Messages postés219Date d'inscriptionlundi 21 novembre 2005StatutMembreDernière intervention20 décembre 20101 18 nov. 2010 à 00:02
Bonsoir
Peut-être ça:
If (Textbox1.Text < 0) And (Textbox1.Text >= -2) Then
Textbox2.Text = moncalcul1
Textbox3.Text = moncalcul2
Textbox4.Text = moncalcul3
ElseIf (Textbox1.Text > 0) And (Textbox1.Text <= 2) Then
Textbox2.Text = moncalcul4
Textbox3.Text = moncalcul5
Textbox4.Text = moncalcul6
End If
If Textbox4.Text < Textbox5.Text Then
Textbox6 = moncalcul7
ElseIf Textbox5.Text < Textbox4.Text Then
Textbox6 = moncalcul8
End If
Il manque le test pour: Textbox1.Text = 0
Il faudrait l'inclure dans l'un ou l'autre "If"
If (Textbox1.Text <= 0) And (Textbox1.Text >= -2) Then
ou
ElseIf (Textbox1.Text >= 0) And (Textbox1.Text <= 2) Then