.net 单击同一按钮的时间间隔如何获取

来源:百度知道 编辑:UC知道 时间:2024/06/10 06:03:01
给点代码行吗? 我的想法是在第一次单击后开始计时 在5秒之内再次单击该按钮时 则不执行 而是给出提示 忘了说是VB 不好意思了

还得是全局的静态变量。然后求差

我建议直接用timer控件,然后再定义一个标志来做

你是win程序还是web程序?
给你个window程序的。
首先拖一个按纽和一个timer,并设置timer的Enable=true和Interval=5000
后台代码为:
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace forbaidu
{
/// <summary>
/// Form1 的摘要说明。
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Timer timer1;
private System.ComponentModel.IContainer components;
private bool flag=true;
public Form1()
{
//
// Windows 窗体设计器支持所必需的
//
InitializeComponent();

//
// TODO: 在 InitializeComponent 调用后添加任何构造函数代码
//
}

/// <summary>
/// 清理所有正在使用的资源。
/// </summary&