VB点虐 点击计数器 vb计数函数
vb点虐 计数
因为你每点击一次,就执行一次这个按钮事件,就又重新定义count,又从0开始
创新互联是专业的炎陵网站建设公司,炎陵接单;提供成都网站建设、网站设计,网页设计,网站设计,建网站,PHP网站建设等专业做网站服务;采用PHP框架,可快速的进行炎陵网站开发网页制作和功能扩展;专业做搜索引擎喜爱的网站,专业的做网站团队,希望更多企业前来合作!
你把count直接放在类名下面:就是
public class form1
dim count as integer=0
然后把你这个事件里边Private conut As Integer这句删去就可以了
vb点虐 中怎么获取button被点击的次数
定义一个全局的静态变量,例如
Dim Shared c As Integer
在 button 的 click 时间里写入 c = c + 1
这个 c 就是 点击次数了
vb鼠标点击计数器
请将下面的代码复制到记事本中,然后重命名为 Form1.frm
切记后缀名为 frm
然后VB就能打开下面的窗体并加载好控件。
* 以下为代码区。
************************************
VERSION 5.00
Begin VB.Form Form1
Caption = "点击次数显示"
ClientHeight = 2670
ClientLeft = 60
ClientTop = 450
ClientWidth = 5415
LinkTopic = "Form1"
ScaleHeight = 2670
ScaleWidth = 5415
StartUpPosition = 3 '窗口缺省
Begin VB.CommandButton Command4
Caption = "清空"
Height = 420
Left = 4185
TabIndex = 4
Top = 1845
Width = 870
End
Begin VB.CommandButton Command3
Caption = "显示"
Height = 420
Left = 2970
TabIndex = 3
Top = 1845
Width = 870
End
Begin VB.CommandButton Command2
Caption = "B"
Height = 420
Left = 1665
TabIndex = 2
Top = 1845
Width = 870
End
Begin VB.CommandButton Command1
Caption = "A"
Height = 420
Left = 450
TabIndex = 1
Top = 1845
Width = 870
End
Begin VB.TextBox Text1
Height = 915
Left = 810
MultiLine = -1 'True
TabIndex = 0
Top = 495
Width = 3840
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private CS_A As Integer
Private CS_B As Integer
Dim I As Integer
Private Sub Command1_Click()
CS_A = CS_A + 1
End Sub
Private Sub Command2_Click()
CS_B = CS_B + 1
End Sub
Private Sub Command3_Click()
Text1.Text = "A 点击次数为:" CS_A " 次"
Text1.Text = Text1.Text + vbCrLf + "B 点击次数为:" CS_B " 次"
End Sub
Private Sub Command4_Click()
CS_A = 0
CS_B = 0
Text1.Text = ""
End Sub
Private Sub Form_Load()
CS_A = 0
CS_B = 0
End Sub
文章名称:VB点虐 点击计数器 vb计数函数
分享链接:http://azwzsj.com/article/ddjcese.html