如何使标签闪烁? [英] How to make a label blink?

查看:125
本文介绍了如何使标签闪烁?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用微软Visual Studio 2005



当我按下按钮时,如何让标签闪烁3次?

i有此代码:



 私有  Sub  Button1_Click( ByVal  sender  As  System。对象 ByVal  e 作为 System.EventArgs)句柄 Button1.Click 
LBL1.Visible = True
如果 LBL1.Visible = True 然后
LBL1.Visible = 错误
结束 如果
结束 Sub





但它不起作用:/

我该怎么做?< br $>


非常感谢!

解决方案

查看我为您制作的示例程序:

在Windows窗体中

放置一个按钮和Lable:

按钮名称为:Button1

Lable名称为:LBL1

定时器conral as Timer1



声明一个公共整数变量为ival



 '  ---- public variable  
Dim ival As 整数 = 0
' ----按钮单击启动计时器
私有 Sub Button1_Click(发件人 A s 系统。对象,e As System.EventArgs)句柄 Button1.Click
LBL1.Visible = True
Timer1.Interval = 200
Timer1.Enabled = True
ival = 0
Timer1.Start()
LBL1.Visible = True
结束 Sub
' ----计时器勾选事件使您的标签闪烁
私有 Sub Timer1_Tick(发件人 As System。 Object ,e As System.EventArgs) 句柄 Timer1.Tick
如果 LBL1.Visible = True 然后
LBL1.Visible = False
Else
LBL1.Visible = True
结束 如果
ival = ival + 1
如果 ival = 7 然后
如果 LBL1.Visible = False 然后
LBL1.Visible = True
结束 如果
Timer1 。停止()
结束 如果

结束 Sub


< blockquote>



使用以下链接



http://stackoverflow.com/questions/3404228/how-to-blink-a-label-in-asp-net [ ^ ]



http://www.dotnetspider.com/forum/126647-blinking-text-ASP.aspx [ ^ ]





尝试这个

 <  正文    onload   =  changeColour('flashtext'); >  

< script type = text / javascript >

函数changeColour(elementId){
var interval = 1000;
var colour1 =#ff0000;
var colour2 =#000000;
if(document.getElementById){
var element = document.getElementById(elementId);
element.style.color =(element.style.color == colour1)? colour2:colour1;
setTimeout(changeColour('+ elementId +'),interval);
}
}

< / script >

< p id = flashtext > 此文字将闪烁!!! < ; / p > < / body >


I am using microsoft Visual Studio 2005

How do I make a label blink 3 times when i push a button?
i have this code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    LBL1.Visible = True
    If LBL1.Visible = True Then
        LBL1.Visible = False
    End If
End Sub



but it doesnt work :/
how do i do it?

super thanks!

解决方案

Check this sample program i made for you :
In windows form
place one Button and Lable:
Button Name as :Button1
Lable Name as :LBL1
Timer conral as Timer1

Declare one public integer variable as ival

' ----  public variable
 Dim ival As Integer = 0
' ----  Button Click Start the Timer
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        LBL1.Visible = True
        Timer1.Interval = 200
        Timer1.Enabled = True
        ival = 0
        Timer1.Start()
        LBL1.Visible = True
    End Sub
' ----  Timer Tick Event blink your label
    Private Sub Timer1_Tick(sender As System.Object, e As System.EventArgs) Handles Timer1.Tick
        If LBL1.Visible = True Then
            LBL1.Visible = False
        Else
            LBL1.Visible = True
        End If
        ival = ival + 1
        If ival = 7 Then
            If LBL1.Visible = False Then
                LBL1.Visible = True
            End If
            Timer1.Stop()
        End If

    End Sub


Hi,

Use below links

http://stackoverflow.com/questions/3404228/how-to-blink-a-label-in-asp-net[^]

http://www.dotnetspider.com/forum/126647-blinking-text-ASP.aspx[^]

or
try this

<body onload="changeColour('flashtext');">

<script type="text/javascript">

function changeColour(elementId) {
    var interval = 1000;
    var colour1 = "#ff0000";
    var colour2 = "#000000";
    if (document.getElementById) {
        var element = document.getElementById(elementId);
        element.style.color = (element.style.color == colour1) ? colour2 : colour1;
        setTimeout("changeColour('" + elementId + "')", interval);
    }
}

</script>

<p id="flashtext">This text will flash!!!</p></body>


这篇关于如何使标签闪烁?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆