vb如何编辑再次点击button事件
展开全部
添加一个按钮,一个计时器,一个标签。
复制以下代码即可:
Option Explicit
Private Sub Command1_Click()
Static n
n = n + 1
If n Mod 2 = 0 Then
Command1.Caption = "启动"
Timer1.Enabled = False
Else
Command1.Caption = "停止"
Timer1.Interval = 1000
Timer1.Enabled = True
End If
End Sub
Private Sub Form_Load()
Form1.Caption = "霓虹灯"
Command1.Caption = "启动"
Label1.AutoSize = True
Label1.Caption = "欢迎学习Visual Basic程序设计"
Label1.Font.Size = 12
End Sub
Private Sub Timer1_Timer()
Static m%
If m < 7 Then
m = m + 1
Else
m = 0
m = m + 1
End If
Select Case m
Case Is = 1
Label1.ForeColor = RGB(255, 0, 0)
Case Is = 2
Label1.ForeColor = RGB(0, 255, 0)
Case Is = 3
Label1.ForeColor = RGB(0, 0, 255)
Case Is = 4
Label1.ForeColor = RGB(255, 255, 0)
Case Is = 5
Label1.ForeColor = RGB(255, 128, 10)
Case Is = 6
Label1.ForeColor = RGB(139, 0, 255)
Case Is = 7
Label1.ForeColor = RGB(0, 0, 0)
End Select
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询