求做一个VB程序 按钮计数
作者&投稿:霍池 (若有异议请与网页底部的电邮联系)
Option Explicit
Private Sub Command1_Click()
Me.Tag = Me.Tag + 1
Print Me.Tag
End SubPrivate Sub Form_Load()
Me.Tag = 0
End Sub
呵呵 需要加timer控件
Option Explicit
Dim A As Integer
Dim B As Integer
Private Sub Command1_Click()
A = A + 1
End Sub
Private Sub Command2_Click()
B = B + 1
End Sub
Private Sub Command3_Click()
Label1.Caption = "A按钮按下次数:" & A & " B按钮按下次数:" & B
'初始化A、B以便于下次统计
A = 0: B = 0
End Sub
效果:
聂宋哈力: Option Explicit Dim A As Integer Dim B As Integer Private Sub Command1_Click() A = A + 1 End Sub Private Sub Command2_Click() B = B + 1 End Sub Private Sub Command3_Click() Label1.Caption = "A按钮按下次数:" & A & " B按钮按下次数:" & B '初始化A、B以便于下次统计 A = 0: B = 0 End Sub效果:
固阳县19387458351: 求一个vb程序 计数的 最好是 按一下按钮加1 并且能看到总计数的 - ?
聂宋哈力: Option Explicit Private Sub Command1_Click() Me.Tag = Me.Tag + 1 Print Me.Tag End SubPrivate Sub Form_Load() Me.Tag = 0 End Sub
固阳县19387458351: vb 计数代码 - ?
聂宋哈力: Private Sub Command1_Click() Static a As Integer a = a + 1 Print a End Sub
固阳县19387458351: 怎么制作vb计数器 - ?
聂宋哈力: 兄弟,接招! Private Sub C1_Click() T1.Enabled = True End SubPrivate Sub Form_Load() T1.Enabled = False T1.Interval = 1000 Text1.Text = 0 C1.Caption = "开始计数" End SubPrivate Sub T1_Timer() Text1.Text = Text1.Text + 1 End Sub
固阳县19387458351: 求个VB实现简单计数器的代码 - ?
聂宋哈力: 新建一个VB工程,双击窗体把复制下面代码即可.Option Explicit Private sCount As Long Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) Select Case KeyCode Case 49 '加1 If Shift = 2 Then Form1.Caption = "CTRL + 1" ...
固阳县19387458351: VB 如果制作一个计数器 - ?
聂宋哈力: Dim I As IntegerPrivate Sub Command1_Click()I = I + 1Print IEnd SubPrivate Sub Form_Load()I = 0End Sub
固阳县19387458351: VB中怎么设置一个按钮计数器? - ?
聂宋哈力: 按钮事件中加入if判断,如果是caption属性是开始的名字,caption改成第一次的值,如果是caption属性已经等于改变的值,就开始执行你要的操作.
固阳县19387458351: 用VB编写程序,在文本框1中输入一段文本,单击“统计”按钮,分别统计英文字母和数字符的个数并显示出来 - ?
聂宋哈力: Private Sub Command1_Click() Dim sz As Integer, zm As Integer For I = 1 To Len(Text1.Text) Select Case Mid(Text1.Text, I, 1) Case "A" To "Z", "a" To "z" zm = zm + 1 Case "0" To "9" sz = sz + 1 End Select Next I Text2.Text = "字母的个数为:" & zm Text3.Text = "数字的个数为:" & sz End Sub
固阳县19387458351: 用vb设计一个程序由用户输入两个数单击“求和”按扭可以将这两个数的和显示出来 - ?
聂宋哈力: 添加一个按钮,复制以下代码运行即可:Private Sub Command1_Click() MsgBox "和:" & (Val(InputBox("请输入第一个数字:")) + Val(InputBox("请输入第二个数字:"))) End Sub
固阳县19387458351: 求一个VB统计小程序 - ?
聂宋哈力: Private Sub Command1_Click() '记录 If IsNumeric(Text1.Text) Then Open "D:\jilu.txt" For Append As #1 '打开记录文件 Print #1, Date; "|"; '保存日期 Print #1, Text1.Text '保存盈利值 Close #1 '关闭文件 Else MsgBox "请输入数字!", ...