Se connecter / S'enregistrer
Votre question

C# programme probleme

Tags :
  • Standard
  • Programmation
Dernière réponse : dans Programmation
8 Novembre 2004 19:54:59

Bonjour, j'essaye d'executer ce programme en c#

  1. /*
  2. * Created by SharpDevelop.
  3. * User: Zip
  4. * Date: 03/11/2004
  5. * Time: 00:56
  6. *
  7. * To change this template use Tools | Options | Coding | Edit Standard Headers.
  8. */
  9. using System;
  10. using System.Drawing;
  11. using System.Windows.Forms;
  12.  
  13. namespace aaaaa
  14. {
  15. /// <summary>
  16. /// Description of MainForm.
  17. /// </summary>
  18. public class MainForm : System.Windows.Forms.Form
  19. {
  20. private System.Windows.Forms.TextBox txb_ded;
  21. private System.Windows.Forms.Label lbl_ded;
  22. private System.Windows.Forms.Label lbl_rti;
  23. private System.Windows.Forms.Button btn_rec;
  24. private System.Windows.Forms.Label lbl_puiss;
  25. private System.Windows.Forms.TextBox txb_puiss;
  26. private System.Windows.Forms.TextBox txb_rest;
  27. private System.Windows.Forms.Label lbl_rni;
  28. private System.Windows.Forms.Button btn_quit;
  29. private System.Windows.Forms.RadioButton rdb_fr;
  30. private System.Windows.Forms.TextBox txb_dis;
  31. private System.Windows.Forms.Label lbl_rest;
  32. private System.Windows.Forms.Label lbl_abat;
  33. private System.Windows.Forms.Button btn_calc;
  34. private System.Windows.Forms.RadioButton rdb_forf;
  35. private System.Windows.Forms.Label lbl_dis;
  36. private System.Windows.Forms.GroupBox grp_ded;
  37. private System.Windows.Forms.TextBox txb_rni;
  38. private System.Windows.Forms.TextBox txb_rti;
  39. private System.Windows.Forms.TextBox txb_abat;
  40. public MainForm()
  41. {
  42. //
  43. // The InitializeComponent() call is required for Windows Forms designer support.
  44. //
  45. InitializeComponent();
  46.  
  47. //
  48. // TODO: Add constructor code after the InitializeComponent() call.
  49. //
  50. }
  51.  
  52. [STAThread]
  53. public static void Main(string[] args)
  54. {
  55. Application.Run(new MainForm());
  56. }
  57.  
  58. #region Windows Forms Designer generated code
  59. /// <summary>
  60. /// This method is required for Windows Forms designer support.
  61. /// Do not change the method contents inside the source code editor. The Forms designer might
  62. /// not be able to load this method if it was changed manually.
  63. /// </summary>
  64. private void InitializeComponent() {
  65. this.txb_abat = new System.Windows.Forms.TextBox();
  66. this.txb_rti = new System.Windows.Forms.TextBox();
  67. this.txb_rni = new System.Windows.Forms.TextBox();
  68. this.grp_ded = new System.Windows.Forms.GroupBox();
  69. this.lbl_dis = new System.Windows.Forms.Label();
  70. this.rdb_forf = new System.Windows.Forms.RadioButton();
  71. this.btn_calc = new System.Windows.Forms.Button();
  72. this.lbl_abat = new System.Windows.Forms.Label();
  73. this.lbl_rest = new System.Windows.Forms.Label();
  74. this.txb_dis = new System.Windows.Forms.TextBox();
  75. this.rdb_fr = new System.Windows.Forms.RadioButton();
  76. this.btn_quit = new System.Windows.Forms.Button();
  77. this.lbl_rni = new System.Windows.Forms.Label();
  78. this.txb_rest = new System.Windows.Forms.TextBox();
  79. this.txb_puiss = new System.Windows.Forms.TextBox();
  80. this.lbl_puiss = new System.Windows.Forms.Label();
  81. this.btn_rec = new System.Windows.Forms.Button();
  82. this.lbl_rti = new System.Windows.Forms.Label();
  83. this.lbl_ded = new System.Windows.Forms.Label();
  84. this.txb_ded = new System.Windows.Forms.TextBox();
  85. this.grp_ded.SuspendLayout();
  86. this.SuspendLayout();
  87. //
  88. // txb_abat
  89. //
  90. this.txb_abat.Location = new System.Drawing.Point(168, 288);
  91. this.txb_abat.Name = "txb_abat";
  92. this.txb_abat.ReadOnly = true;
  93. this.txb_abat.TabIndex = 15;
  94. this.txb_abat.Text = "";
  95. //
  96. // txb_rti
  97. //
  98. this.txb_rti.Location = new System.Drawing.Point(176, 16);
  99. this.txb_rti.Name = "txb_rti";
  100. this.txb_rti.Size = new System.Drawing.Size(88, 20);
  101. this.txb_rti.TabIndex = 7;
  102. this.txb_rti.Text = "";
  103. //
  104. // txb_rni
  105. //
  106. this.txb_rni.Location = new System.Drawing.Point(168, 320);
  107. this.txb_rni.Name = "txb_rni";
  108. this.txb_rni.ReadOnly = true;
  109. this.txb_rni.TabIndex = 17;
  110. this.txb_rni.Text = "";
  111. //
  112. // grp_ded
  113. //
  114. this.grp_ded.Controls.Add(this.txb_dis);
  115. this.grp_ded.Controls.Add(this.txb_puiss);
  116. this.grp_ded.Controls.Add(this.lbl_dis);
  117. this.grp_ded.Controls.Add(this.lbl_puiss);
  118. this.grp_ded.Controls.Add(this.rdb_fr);
  119. this.grp_ded.Controls.Add(this.rdb_forf);
  120. this.grp_ded.Location = new System.Drawing.Point(40, 56);
  121. this.grp_ded.Name = "grp_ded";
  122. this.grp_ded.Size = new System.Drawing.Size(328, 160);
  123. this.grp_ded.TabIndex = 8;
  124. this.grp_ded.TabStop = false;
  125. this.grp_ded.Text = "Déduction";
  126. //
  127. // lbl_dis
  128. //
  129. this.lbl_dis.Location = new System.Drawing.Point(88, 120);
  130. this.lbl_dis.Name = "lbl_dis";
  131. this.lbl_dis.TabIndex = 3;
  132. this.lbl_dis.Text = "Distance";
  133. this.lbl_dis.Visible = false;
  134. //
  135. // rdb_forf
  136. //
  137. this.rdb_forf.Location = new System.Drawing.Point(40, 24);
  138. this.rdb_forf.Name = "rdb_forf";
  139. this.rdb_forf.TabIndex = 0;
  140. this.rdb_forf.Text = "Forfaitaire";
  141. this.rdb_forf.CheckedChanged += new System.EventHandler(this.Rdb_forfCheckedChanged);
  142. //
  143. // btn_calc
  144. //
  145. this.btn_calc.Location = new System.Drawing.Point(200, 360);
  146. this.btn_calc.Name = "btn_calc";
  147. this.btn_calc.TabIndex = 9;
  148. this.btn_calc.Text = "Calculer";
  149. this.btn_calc.Click += new System.EventHandler(this.Btn_calcClick);
  150. //
  151. // lbl_abat
  152. //
  153. this.lbl_abat.Location = new System.Drawing.Point(48, 288);
  154. this.lbl_abat.Name = "lbl_abat";
  155. this.lbl_abat.Size = new System.Drawing.Size(112, 23);
  156. this.lbl_abat.TabIndex = 14;
  157. this.lbl_abat.Text = "Abattement de 20%";
  158. //
  159. // lbl_rest
  160. //
  161. this.lbl_rest.Location = new System.Drawing.Point(48, 256);
  162. this.lbl_rest.Name = "lbl_rest";
  163. this.lbl_rest.TabIndex = 12;
  164. this.lbl_rest.Text = "Reste Net";
  165. //
  166. // txb_dis
  167. //
  168. this.txb_dis.Location = new System.Drawing.Point(200, 120);
  169. this.txb_dis.Name = "txb_dis";
  170. this.txb_dis.TabIndex = 5;
  171. this.txb_dis.Text = "";
  172. this.txb_dis.Visible = false;
  173. //
  174. // rdb_fr
  175. //
  176. this.rdb_fr.Location = new System.Drawing.Point(40, 56);
  177. this.rdb_fr.Name = "rdb_fr";
  178. this.rdb_fr.TabIndex = 1;
  179. this.rdb_fr.Text = "Frais réels";
  180. this.rdb_fr.CheckedChanged += new System.EventHandler(this.Rdb_frCheckedChanged);
  181. //
  182. // btn_quit
  183. //
  184. this.btn_quit.Location = new System.Drawing.Point(304, 360);
  185. this.btn_quit.Name = "btn_quit";
  186. this.btn_quit.TabIndex = 19;
  187. this.btn_quit.Text = "Quitter";
  188. this.btn_quit.Click += new System.EventHandler(this.Btn_quitClick);
  189. //
  190. // lbl_rni
  191. //
  192. this.lbl_rni.Location = new System.Drawing.Point(48, 320);
  193. this.lbl_rni.Name = "lbl_rni";
  194. this.lbl_rni.Size = new System.Drawing.Size(120, 23);
  195. this.lbl_rni.TabIndex = 16;
  196. this.lbl_rni.Text = "Revenu Net Imposable";
  197. //
  198. // txb_rest
  199. //
  200. this.txb_rest.Location = new System.Drawing.Point(168, 256);
  201. this.txb_rest.Name = "txb_rest";
  202. this.txb_rest.ReadOnly = true;
  203. this.txb_rest.TabIndex = 13;
  204. this.txb_rest.Text = "";
  205. //
  206. // txb_puiss
  207. //
  208. this.txb_puiss.Location = new System.Drawing.Point(200, 88);
  209. this.txb_puiss.Name = "txb_puiss";
  210. this.txb_puiss.TabIndex = 4;
  211. this.txb_puiss.Text = "";
  212. this.txb_puiss.Visible = false;
  213. //
  214. // lbl_puiss
  215. //
  216. this.lbl_puiss.Location = new System.Drawing.Point(88, 88);
  217. this.lbl_puiss.Name = "lbl_puiss";
  218. this.lbl_puiss.TabIndex = 2;
  219. this.lbl_puiss.Text = "Puissance";
  220. this.lbl_puiss.Visible = false;
  221. //
  222. // btn_rec
  223. //
  224. this.btn_rec.Location = new System.Drawing.Point(88, 360);
  225. this.btn_rec.Name = "btn_rec";
  226. this.btn_rec.Size = new System.Drawing.Size(88, 24);
  227. this.btn_rec.TabIndex = 18;
  228. this.btn_rec.Text = "Recommencer";
  229. this.btn_rec.Click += new System.EventHandler(this.Btn_recClick);
  230. //
  231. // lbl_rti
  232. //
  233. this.lbl_rti.Location = new System.Drawing.Point(40, 16);
  234. this.lbl_rti.Name = "lbl_rti";
  235. this.lbl_rti.Size = new System.Drawing.Size(128, 23);
  236. this.lbl_rti.TabIndex = 0;
  237. this.lbl_rti.Text = "Revenu Total Imposable";
  238. //
  239. // lbl_ded
  240. //
  241. this.lbl_ded.Location = new System.Drawing.Point(48, 224);
  242. this.lbl_ded.Name = "lbl_ded";
  243. this.lbl_ded.TabIndex = 10;
  244. this.lbl_ded.Text = "Déduction 10%";
  245. //
  246. // txb_ded
  247. //
  248. this.txb_ded.Location = new System.Drawing.Point(168, 224);
  249. this.txb_ded.Name = "txb_ded";
  250. this.txb_ded.ReadOnly = true;
  251. this.txb_ded.TabIndex = 11;
  252. this.txb_ded.Text = "";
  253. //
  254. // MainForm
  255. //
  256. this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  257. this.ClientSize = new System.Drawing.Size(472, 398);
  258. this.Controls.Add(this.btn_quit);
  259. this.Controls.Add(this.btn_rec);
  260. this.Controls.Add(this.txb_rni);
  261. this.Controls.Add(this.lbl_rni);
  262. this.Controls.Add(this.txb_abat);
  263. this.Controls.Add(this.lbl_abat);
  264. this.Controls.Add(this.txb_rest);
  265. this.Controls.Add(this.lbl_rest);
  266. this.Controls.Add(this.txb_ded);
  267. this.Controls.Add(this.lbl_ded);
  268. this.Controls.Add(this.btn_calc);
  269. this.Controls.Add(this.grp_ded);
  270. this.Controls.Add(this.txb_rti);
  271. this.Controls.Add(this.lbl_rti);
  272. this.Name = "MainForm";
  273. this.Text = "Calcul d\'impôt";
  274. this.grp_ded.ResumeLayout(false);
  275. this.ResumeLayout(false);
  276. }
  277. #endregion
  278. void Btn_calcClick(object sender, System.EventArgs e)
  279. {
  280.  
  281. //Calcul d'impôt déduction forfaitaire
  282. const double tauxfor=0.1;
  283. int ded=0, rest=0, abat=0, rni=0, rti=0;
  284. if (rdb_forf.Checked == true)
  285. {
  286. //Calcul de la déduction de 10%
  287. rti = (int)(Convert.ToInt32(txb_rti.Text));
  288. ded = (int)(rti * tauxfor);
  289. txb_ded.Text = Convert.ToString( ded );
  290.  
  291. //Calcul du reste net
  292. rest = (int)(rti - ded);
  293. txb_rest.Text = Convert.ToString(rest);
  294.  
  295. //Calcul Abattement de 20 %
  296. abat = (int)(rest * 0.2);
  297. txb_abat.Text = Convert.ToString(abat);
  298.  
  299. //Calcul Revenu Net Imposable
  300. rni = (int)(rest - abat);
  301. txb_rni.Text = Convert.ToString(rni);
  302. }
  303. else
  304. {
  305. if (Convert.ToInt32(txb_puiss.Text) <= 7)
  306. {
  307. if (Convert.ToInt32(txb_dis.Text) <= 5000)
  308. {
  309. //Calcul du taux de frais réels
  310. ded = (int)(Convert.ToInt32(txb_dis.Text) * 0.469);
  311. txb_ded.Text = Convert.ToString ( ded);
  312.  
  313. //Calcul du reste net
  314. rest = ((Convert.ToInt32(txb_rti.Text)) - (Convert.ToInt32(txb_ded.Text)));
  315. txb_rest.Text = Convert.ToString(rest);
  316.  
  317. //Calcul Abattement de 20 %
  318. abat = ((int)(Convert.ToInt32(txb_rest.Text) * 0.2));
  319. txb_abat.Text = Convert.ToString(abat);
  320.  
  321. //Calcul Revenu Net Imposable
  322. rni = ((Convert.ToInt32(txb_rest.Text) - Convert.ToInt32(txb_abat.Text)));
  323. txb_rni.Text = Convert.ToString(rni);
  324. }
  325. if (Convert.ToInt32(txb_dis.Text) <= 20000 && (Convert.ToInt32(txb_dis.Text) > 5000 ))
  326. {
  327. //Calcul du taux de frais réels
  328. ded = (int)(1060 + (Convert.ToInt32(txb_dis.Text) * 0.257));
  329. txb_ded.Text = Convert.ToString ( ded);
  330.  
  331. //Calcul du reste net
  332. rest = ((Convert.ToInt32(txb_rti.Text)) - (Convert.ToInt32(txb_ded.Text)));
  333. txb_rest.Text = Convert.ToString(rest);
  334.  
  335. //Calcul Abattement de 20 %
  336. abat = ((int)(Convert.ToInt32(txb_rest.Text) * 0.2));
  337. txb_abat.Text = Convert.ToString(abat);
  338.  
  339. //Calcul Revenu Net Imposable
  340. rni = ((Convert.ToInt32(txb_rest.Text) - Convert.ToInt32(txb_abat.Text)));
  341. txb_rni.Text = Convert.ToString(rni);
  342. }
  343. if (Convert.ToInt32(txb_dis.Text) > 20000 )
  344. {
  345. //Calcul du taux de frais réels
  346. ded = (int)(Convert.ToInt32(txb_dis.Text) * 0.310);
  347. txb_ded.Text = Convert.ToString ( ded);
  348.  
  349. //Calcul du reste net
  350. rest = ((Convert.ToInt32(txb_rti.Text)) - (Convert.ToInt32(txb_ded.Text)));
  351. txb_rest.Text = Convert.ToString(rest);
  352.  
  353. //Calcul Abattement de 20 %
  354. abat = ((int)(Convert.ToInt32(txb_rest.Text) * 0.2));
  355. txb_abat.Text = Convert.ToString(abat);
  356.  
  357. //Calcul Revenu Net Imposable
  358. rni = ((Convert.ToInt32(txb_rest.Text) - Convert.ToInt32(txb_abat.Text)));
  359. txb_rni.Text = Convert.ToString(rni);
  360. }
  361. }
  362. }
  363. {
  364. if (Convert.ToInt32(txb_puiss.Text) > 7)
  365. {
  366. if (Convert.ToInt32(txb_dis.Text) <= 5000)
  367. {
  368. //Calcul du taux de frais réels
  369. ded = (int)(Convert.ToInt32(txb_dis.Text) * 0.598);
  370. txb_ded.Text = Convert.ToString ( ded);
  371.  
  372. //Calcul du reste net
  373. rest = ((Convert.ToInt32(txb_rti.Text)) - (Convert.ToInt32(txb_ded.Text)));
  374. txb_rest.Text = Convert.ToString(rest);
  375.  
  376. //Calcul Abattement de 20 %
  377. abat = ((int)(Convert.ToInt32(txb_rest.Text) * 0.2));
  378. txb_abat.Text = Convert.ToString(abat);
  379.  
  380. //Calcul Revenu Net Imposable
  381. rni = ((Convert.ToInt32(txb_rest.Text) - Convert.ToInt32(txb_abat.Text)));
  382. txb_rni.Text = Convert.ToString(rni);
  383. }
  384. if (Convert.ToInt32(txb_dis.Text) <= 20000 && (Convert.ToInt32(txb_dis.Text) > 5000 ))
  385. {
  386. //Calcul du taux de frais réels
  387. ded = (int)(1280 + (Convert.ToInt32(txb_dis.Text) * 0.342));
  388. txb_ded.Text = Convert.ToString ( ded);
  389.  
  390. //Calcul du reste net
  391. rest = ((Convert.ToInt32(txb_rti.Text)) - (Convert.ToInt32(txb_ded.Text)));
  392. txb_rest.Text = Convert.ToString(rest);
  393.  
  394. //Calcul Abattement de 20 %
  395. abat = ((int)(Convert.ToInt32(txb_rest.Text) * 0.2));
  396. txb_abat.Text = Convert.ToString(abat);
  397.  
  398. //Calcul Revenu Net Imposable
  399. rni = ((Convert.ToInt32(txb_rest.Text) - Convert.ToInt32(txb_abat.Text)));
  400. txb_rni.Text = Convert.ToString(rni);
  401. }
  402. if (Convert.ToInt32(txb_dis.Text) > 20000 )
  403. {
  404. //Calcul du taux de frais réels
  405. ded = (int)(Convert.ToInt32(txb_dis.Text) * 0.406);
  406. txb_ded.Text = Convert.ToString ( ded);
  407.  
  408. //Calcul du reste net
  409. rest = ((Convert.ToInt32(txb_rti.Text)) - (Convert.ToInt32(txb_ded.Text)));
  410. txb_rest.Text = Convert.ToString(rest);
  411.  
  412. //Calcul Abattement de 20 %
  413. abat = ((int)(Convert.ToInt32(txb_rest.Text) * 0.2));
  414. txb_abat.Text = Convert.ToString(abat);
  415.  
  416. //Calcul Revenu Net Imposable
  417. rni = ((Convert.ToInt32(txb_rest.Text) - Convert.ToInt32(txb_abat.Text)));
  418. txb_rni.Text = Convert.ToString(rni);
  419. }
  420. }
  421. }
  422. }
  423. void Rdb_forfCheckedChanged(object sender, System.EventArgs e)
  424. {
  425. lbl_puiss.Visible = false;
  426. lbl_dis.Visible = false;
  427. txb_puiss.Visible = false;
  428. txb_dis.Visible = false;
  429. }
  430.  
  431. void Rdb_frCheckedChanged(object sender, System.EventArgs e)
  432. {
  433. lbl_puiss.Visible = true;
  434. lbl_dis.Visible = true;
  435. txb_puiss.Visible = true;
  436. txb_dis.Visible = true;
  437. }
  438.  
  439. void Btn_recClick(object sender, System.EventArgs e)
  440. {
  441. txb_rti.Text = "";
  442. txb_dis.Text = "";
  443. txb_puiss.Text = "";
  444. txb_rest.Text = "";
  445. txb_abat.Text = "";
  446. txb_rni.Text = "";
  447. txb_ded.Text = "";
  448. }
  449.  
  450. void Btn_quitClick(object sender, System.EventArgs e)
  451. {
  452. Application.Exit();
  453. }
  454.  
  455. }
  456. }


Mais, lorsque je fais un calcul forfaitaire, il me dit qu'il y a une erreur, une exception non gérée ......
Sa fait des heures que je suis dessus alors une petite aide me ferait pas de mal ....

Autres pages sur : programme probleme

8 Novembre 2004 20:13:05

T'aurais pas une idée d'ou se situerai l'erreur?
Car vu l'immensité du code, je risque pas de la trouver sans perdre un oeil.
8 Novembre 2004 20:22:07

lol mdrr, bon j'ai réussi tout seul à trouver l'erreur enfin je ne l'ai pas retrouver j'ai fait un peu de rangement, puis un copier coller avec moderation pour tester le programme au fur à mesure...
Je pense que j'ai du faire une gaffe mais franchement je sais pas c'est quoi mais maintenant sa marche merci quand même...
Contenus similaires
8 Novembre 2004 22:10:11

Oki ;-).
Si t'as un problème lors de la compilation, met quelques infos dans ton programme qui t'informes du déroulement de celui ci.

Genre il t'affiche la valeur de chaque variable au fur et a mesure, meme si les debug sont la pour ça.
Et tant mieux si ta trouver d'ou sa venait, on auras pas a chercher ;-)
30 Mars 2011 17:28:49

bonjour,
j'ai presque le mm pb je veux récupérer un tableau qui contient 2 valeurs représentant le max et min ms ça me donne pas directement l'erreur car une fois que je clique sur le bouton qui doit afficher ce tab il écrit System.Int32[] au lieu d'ecrire les val de tableau.
Merci d'avance
a c 232 L Programmation
30 Mars 2011 21:59:36

Salut,

C'est parce que tu affiches le ToString() du tableau et pas de ses valeurs.
Mais vu que j'ai oublié ma boucle de cristal, je ne peux pas te dire quel est le soucis dans ton code.
Tom's guide dans le monde
  • Allemagne
  • Italie
  • Irlande
  • Royaume Uni
  • Etats Unis
Suivre Tom's Guide
Inscrivez-vous à la Newsletter
  • ajouter à twitter
  • ajouter à facebook
  • ajouter un flux RSS