[VB.NET]动态标题

动态标题

实例说明

在本实例中,我们制作一个窗体的标题是动态变化的应用程序。程序启动时,窗体的标题就开始变化。程序运行结果如图95-1所示。

<script type="text/javascript"> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script>

图95-1 运行结果

技术要点

l 使用Timer控件

l 更改窗体的标题

实现过程

■ 新建项目

打开Visual Studio.NET,选择"新建项目",在项目类型窗口中选择"Visual Basic项目",在模板窗口中选择"Windows应用程序",在名称域中输入"DynCaption",然后选择保存路径。单击"确认"。

■ 添加控件和设置属性

向当前窗体上添加一个Label控件和一个Timer控件,将Label控件的Text属性改为和界面一致。Timer控件的Interval属性设为200(ms),Enabled属性设置为True(默认值为False)。

■ 添加代码

Public Class Form1

Inherits System.Windows.Forms.Form

Dim strword As String

Dim startword As Short

Friend WithEvents Label1 As System.Windows.Forms.Label

Dim textword As String = "欢迎使用VB.NET!"

#Region " Windows Form Designer generated code "

Public Sub New()

MyBase.New()

InitializeComponent()

Me.Text = ""

startword = 1

End Sub

#End Region

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

strword = Mid(textword, startword, 1)

Me.Text = Me.Text & strword

If startword > Len(textword) Then

Me.Text = ""

startword = 1

End If

Beep()

startword = startword + 1

End Sub

End Class

■ 运行程序

单击菜单"调试|启动"或单击 图标运行程序。

小结

本实例通过使用Timer控件来控制窗体标题的变动。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值