Advertisement
Guest User

programminoditthoonee

a guest
May 21st, 2018
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.87 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace loginform
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.         }
  19.  
  20.         private void label2_Click(object sender, EventArgs e)
  21.         {
  22.                    }
  23.  
  24.         private void button1_Click(object sender, EventArgs e)
  25.         {
  26.             string a;
  27.             char lett;
  28.             bool maiusc=false;
  29.             bool num = false;
  30.             bool minusc=false;
  31.             a = pasw.Text;
  32.  
  33.             if(a.Length<8)
  34.                 MessageBox.Show("troppo corto");
  35.  
  36.             for (int i = 0; i < a.Length; i++)
  37.             {
  38.                 //lett = Convert.ToChar(a.Substring(i, 1));
  39.                 lett= a.ElementAt(i);
  40.                 if (lett >= 'A' && lett <= 'Z')
  41.                     maiusc = true;
  42.                 if (lett > 'a' && lett <= 'z')
  43.                     minusc = true;
  44.                 if (lett >= '0' && lett <= '9')
  45.                     num = true;              
  46.             }
  47.             if (maiusc == true && minusc == true && num == true)
  48.                 MessageBox.Show("valida");
  49.             if (maiusc == false && minusc == true && num == true)
  50.             {
  51.                 lblcontrol.Visible = true;
  52.                 lblcontrol.ForeColor = Color.Red;
  53.                 lblcontrol.Text = "manca la maiuscola";
  54.  
  55.  
  56.             }
  57.             if (maiusc == true && minusc == false && num == true)
  58.             {
  59.                 lblcontrol.Visible = true;
  60.                 lblcontrol.ForeColor = Color.Red;
  61.                 lblcontrol.Text = "manca la minuscola";
  62.  
  63.  
  64.             }
  65.             if (maiusc == true && minusc == true && num == false)
  66.             {
  67.                 lblcontrol.Visible = true;
  68.                 lblcontrol.ForeColor = Color.Red;
  69.                 lblcontrol.Text = "manca il numero";
  70.  
  71.  
  72.             }
  73.             if (maiusc == false && minusc == false && num == true)
  74.             {
  75.                 lblcontrol.Visible = true;
  76.                 lblcontrol.ForeColor = Color.Red;
  77.                 lblcontrol.Text = "manca la maiuscola e la minuscola";
  78.  
  79.  
  80.             }
  81.             if (maiusc == false && minusc == true && num == false)
  82.             {
  83.                 lblcontrol.Visible = true;
  84.                 lblcontrol.ForeColor = Color.Red;
  85.                 lblcontrol.Text = "manca la maiuscola e il numero";
  86.  
  87.  
  88.             }
  89.             if (maiusc == true && minusc == false && num == false)
  90.             {
  91.                 lblcontrol.Visible = true;
  92.                 lblcontrol.ForeColor = Color.Red;
  93.                 lblcontrol.Text = "manca la minuscola e il numero";
  94.  
  95.  
  96.             }
  97.         }
  98.     }
  99. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement