Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
Numeri Random - Form1.cs

Form1.cs

Caricato da:
Scarica il programma completo

  1. using System;
  2. using System.Drawing;
  3. using System.Collections;
  4. using System.ComponentModel;
  5. using System.Windows.Forms;
  6. using System.Data;
  7. using System.Threading;
  8. using System.Text;
  9.  
  10. namespace NumeriRandomPerEstrazioni
  11. {
  12.         /// <summary>
  13.         /// Descrizione di riepilogo per Form1.
  14.         /// </summary>
  15.         public class Form1 : System.Windows.Forms.Form
  16.         {
  17.                 private System.Windows.Forms.Button button1;
  18.                 /// <summary>
  19.                 /// Variabile di progettazione necessaria.
  20.                 /// </summary>
  21.                 private System.ComponentModel.Container components = null;
  22.  
  23.                 public Form1()
  24.                 {
  25.                         //
  26.                         // Necessario per il supporto di Progettazione Windows Form
  27.                         //
  28.                         InitializeComponent();
  29.  
  30.                         //
  31.                         // TODO: aggiungere il codice del costruttore dopo la chiamata a InitializeComponent
  32.                         //
  33.                 }
  34.  
  35.                 /// <summary>
  36.                 /// Pulire le risorse in uso.
  37.                 /// </summary>
  38.                 protected override void Dispose( bool disposing )
  39.                 {
  40.                         if( disposing )
  41.                         {
  42.                                 if (components != null)
  43.                                 {
  44.                                         components.Dispose();
  45.                                 }
  46.                         }
  47.                         base.Dispose( disposing );
  48.                 }
  49.                 public void Genera()
  50.                 {
  51.                
  52.                         string chars = "123456789";
  53.                         int i2;
  54.                         string r = "";
  55.                         Random rnd = new Random(DateTime.Now.Millisecond);
  56.                         for (int j = 1; j<3; j++)
  57.                         {
  58.                                 i2 = Convert.ToInt32( rnd.Next(0,9) );
  59.                                 r += chars.Substring(i2,1);
  60.                         }
  61.                         MessageBox.Show("Numero Estratto: " + r);
  62.                 }
  63.                
  64.                 #region Codice generato da Progettazione Windows Form
  65.                 /// <summary>
  66.                 /// Metodo necessario per il supporto della finestra di progettazione. Non modificare
  67.                 /// il contenuto del metodo con l'editor di codice.
  68.                 /// </summary>
  69.                 private void InitializeComponent()
  70.                 {
  71.                         this.button1 = new System.Windows.Forms.Button();
  72.                         this.SuspendLayout();
  73.                         //
  74.                         // button1
  75.                         //
  76.                         this.button1.Location = new System.Drawing.Point(112, 56);
  77.                         this.button1.Name = "button1";
  78.                         this.button1.Size = new System.Drawing.Size(80, 24);
  79.                         this.button1.TabIndex = 7;
  80.                         this.button1.Text = "GeNeRa";
  81.                         this.button1.Click += new System.EventHandler(this.button1_Click_1);
  82.                         //
  83.                         // Form1
  84.                         //
  85.                         this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
  86.                         this.ClientSize = new System.Drawing.Size(336, 144);
  87.                         this.Controls.Add(this.button1);
  88.                         this.Name = "Form1";
  89.                         this.Text = "GeNeRa NuMeRi RaNDoM By SaTaNa";
  90.                         this.Load += new System.EventHandler(this.Form1_Load);
  91.                         this.ResumeLayout(false);
  92.  
  93.                 }
  94.                 #endregion
  95.  
  96.                 /// <summary>
  97.                 /// Il punto di ingresso principale dell'applicazione.
  98.                 /// </summary>
  99.                 [STAThread]
  100.                 static void Main()
  101.                 {
  102.                         Application.Run(new Form1());
  103.                 }
  104.  
  105.                 private void Form1_Load(object sender, System.EventArgs e)
  106.                 {
  107.                
  108.                 }
  109.  
  110.                 private void button1_Click(object sender, System.EventArgs e)
  111.                 {
  112.                        
  113.                 }
  114.  
  115.                 private void button1_Click_1(object sender, System.EventArgs e)
  116.                 {
  117.                         Thread t = new Thread(new ThreadStart(Genera));
  118.                         t.Start();
  119.                 }
  120.         }
  121. }