當前位置:編程學習大全網 - 編程軟體 - 在Visual studio 2005的C#編程中,利用窗口應用程序編寫壹個簡單的的密碼驗證程序

在Visual studio 2005的C#編程中,利用窗口應用程序編寫壹個簡單的的密碼驗證程序

建立壹個窗體,三個控件:

壹個Label;

壹個textbox控件,Name為txtPassWord

壹個button按鈕,Name為btnOK

完整程序如下(程序已經測試,應該可以滿足妳的要求)

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

namespace mimachuangti

{

public partial class Form1 : Form

{

int count = 0; //記錄點擊次數

string strpassword = "123";//初始密碼

public Form1()

{

InitializeComponent();

}

private void btnOK_Click(object sender, EventArgs e) //按鈕響應程序

{

if (txtPassWord.Text == strpassword)

{

MessageBox.Show("歡迎進入");

}

else

{

if (count < 2)

{

MessageBox.Show("密碼不正確,請重新輸入");

txtPassWord.Focus();

count++;

}

else

{

MessageBox.Show("輸入錯誤密碼超過三次,系統即將關閉");

this.Close();

}

}

}

}

}

  • 上一篇:八歲二年級小朋友什麽禮物比較合適
  • 下一篇:Linux 裏面的gdb到底是個什麽東西?
  • copyright 2024編程學習大全網