[VB.NET]小闹钟
来源:互联网 发布:linux 更改home空间 编辑:程序博客网 时间:2024/05/01 05:25
实例说明
在本实例中,我们将制作可以实现"计划任务管理器"功能的应用程序。当到达指定时间时,程序能够自动出现提示信息和播放背景音乐。程序运行结果如图64-1所示。
<script type="text/javascript"><!--google_ad_client = "pub-8333940862668978";/* 728x90, 创建于 08-11-30 */google_ad_slot = "4485230109";google_ad_width = 728;google_ad_height = 90;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>图64-1 运行结果
技术要点
l Time函数
l 使用MMControl控件
l 使用CommonDialog控件
实现过程
■ 新建项目
打开Visual Studio.NET,选择"新建项目",在项目类型窗口中选择"Visual Basic项目",在模板窗口中选择"Windows应用程序",在名称域中输入"SimpleClock",然后选择保存路径。单击"确认"。
■ 添加控件
向窗体添加三个Label控件,三个TextBox控件,三个Button控件,一个MMControl控件、一个CommonDialog控件和一个Timer控件。
■ 设置属性
根据运行时的界面,将Label控件和Button控件的Text属性改为和界面一致。其余见表64-1。
表64-1 窗体各控件的属性值
窗体/控件 属性 值
MMControl1 Visible False
Timer1 Interval 1000
AXCommonDialog1 Filter 声音文件|*.wav;*.mid
■ 添加代码
Private Sub Button1_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Button1.Click
Me.WindowState = System.Windows.Forms.FormWindowState.Minimized
End Sub
Private Sub Button3_Click(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Button3.Click
'打开要播放的声音文件
AXCommonDialog1.ShowOpen()
Text3.Text = AXCommonDialog1.FileName
End Sub
Private Sub Timer1_Tick(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles Timer1.Tick
Dim temptime As String
'将前12个小时和后12个小时分开
If Hour(TimeOfDay) > 12 Then
temptime = VB.Left(CStr(TimeOfDay), 5)
Else
temptime = VB.Left(CStr(TimeOfDay), 4)
End If
'如果时间相同,则显示提示信息
If Text1.Text = temptime Then
MMControl1.FileName = Text3.Text
MMControl1.Command = "open"
MMControl1.Command = "play"
Timer1.Enabled = False
MsgBox(Text2.Text, , "小闹钟")
End If
End Sub
■ 运行程序
单击菜单"调试|启动"或单击 图标运行程序。
小结
通过对本实例的学习,我们学习了MMControl、CommonDialog控件的基本使用方法。我们将在后面的实例中介绍一个更实用、有漂亮界面的小闹钟应用程序。
- [VB.NET]小闹钟
- VB.NET小总
- 小闹钟
- [VB.NET]用VB编了个闹钟,,却碰到问题~~
- [VB.NET]小问题, textbox1
- VB.NET视频小总
- vb.net知识小汇总
- [VB.NET]vb.net的一个小问题
- 健康小闹钟 下载
- 开心小闹钟 官网
- 小桂闹钟 bt
- 我的小闹钟
- Android小闹钟
- android 小闹钟
- winform版小闹钟
- winfrom个人小闹钟
- WinForm小闹钟
- WinForm小闹钟
- PowerPoint 2007 for Starters: The Missing Manual [ILLUSTRATED]
- Sql_Server中如何判断表中某列是否存在
- [VB.NET]随机图形
- [VB.NET]简单图形
- Rails for Java Developers [ILLUSTRATED]
- [VB.NET]小闹钟
- 这个冬天不太冷
- [VB.NET]显示鼠标位置
- Mastering TypoScript: Typo3 Website, Template, and Extension Development
- [VB.NET]图片浏览器
- FORM表单
- [VB.NET]读写INI文件
- LINQ: The Future of Data Access in C# 3.0
- [VB.NET]读写注册表