壹個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();
}
}
}
}
}