vb点虐 做闹钟步骤 vb添加时钟控件

用VB编写一个闹钟程序

做一个简单的闹钟程序很简单的。我这里不用if语句。首先我们在窗体上添加一个标签控件,再画一个“闹钟”,将闹钟得interval属性改为1000,双击闹钟,进入闹钟的代码视图,编写代码

创新互联专业为企业提供滕州网站建设、滕州做网站、滕州网站设计、滕州网站制作等企业网站建设、网页设计与制作、滕州企业网站模板建站服务,10年滕州做网站经验,不只是建网站,更提供有价值的思路和整体网络服务。

private

sub

timer1_timer()

label1.caption

=

time

end

sub就行了。谢谢采纳

跪求用vb点虐 做一个小闹钟!!

'加个定时器,textbox ,button,label Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick

Label1.Text = Now

If FF = Now And FF "2001-1-1" And Timer1.Tag = "" Then

Timer1.Tag = "1"

MsgBox("ff")

End If

End Sub Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

FF = TextBox1.Text

Timer1.Tag = ""

End Sub Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

FF = "2001-1-1"

End Sub'声音加个 AxMMControl控件 AxMMControl1.DeviceType = "waveaudio" ''''''''定义播放*.wav格式 AxMMControl1.FileName = "c:\1.wav" ''''''''载入文件, AxMMControl1.Command = "open" ''''''''打开载入的文件

AxMMControl1.From = 0 '从头开始

AxMMControl1.Command = "play"'保存时间,只要设定时把时间保存到文本文件就行,load 事件中读取,并对比是不是超时,.

利用vb点虐 实现小闹钟功能

Private Declare Function mciSendStringA Lib "winmm.dll" _

(ByVal lpstrCommand As String, ByVal lpstrReturnString As String, _

ByVal uReturnLength As Integer, ByVal hwndCallback As Integer) As Integer

Function PlayMidiFile(ByVal MusicFile As String) As Boolean

If System.IO.File.Exists(MusicFile) Then

mciSendStringA("stop music", "", 0, 0)

mciSendStringA("close music", "", 0, 0)

mciSendStringA("open " MusicFile " alias music", "", 0, 0)

PlayMidiFile = mciSendStringA("play music", "", 0, 0) = 0

End If

End Function

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

If TextBox1.Text = TimeOfDay Then

'具体提醒的东西,如你说的播放音乐

PlayMidiFile("自己添加路径")

End If

'时间格式要是这样的16:00:00

'timer的interval要设成1

'你还可以自己细化

End Sub

用vb做一个小闹钟

下面是一个时钟程序代码,你可以参考一下。

Const PI = 3.14159265

Dim H, W, R As Integer '窗体高、宽、圆半径

Private Sub BiaoKe()

Dim I As Integer

'外盘

Circle (W \ 2, H \ 2), R, vbBlue

'中心

Circle (W \ 2, H \ 2), 1, vbWhite

'盘面各点

For I = 0 To 59

If I Mod 5 = 0 Then

Circle (W \ 2 + R * Cos(I * PI / 30), H \ 2 + R * Sin(I * PI / 30)), 2, vbGreen

Else

Circle (W \ 2 + R * Cos(I * PI / 30), H \ 2 + R * Sin(I * PI / 30)), 1, vbWhite

End If

Next I

End Sub

Private Sub Form_Load()

Me.Show

Me.Cls

H = frmTime.ScaleHeight

W = frmTime.ScaleWidth

R = W \ 4

lbTime.Left = (frmTime.ScaleWidth - lbTime.Width) \ 2

lbTime.Top = frmTime.ScaleHeight - R \ 4

End Sub

Private Sub Form_Resize()

Call Form_Load

End Sub

Private Sub Timer1_Timer()

Dim T1, T2, T3 As Integer

Dim I, J, K As Integer

Me.Cls

T1 = Hour(Time): T2 = Minute(Time): T3 = Second(Time)

I = T1 - 15

J = T2 - 15

K = T3 - 15

'钟表外壳

Call BiaoKe

'画时针

Line (W \ 2, H \ 2)-(W \ 2 + 0.5 * (R * Cos((I + J / 60) * PI / 6)), H \ 2 + 0.5 * (R * Sin((I + J / 60) * PI / 6))), vbGreen

'画分针

Line (W \ 2, H \ 2)-(W \ 2 + 0.7 * (R * Cos((J + K / 60) * PI / 30)), H \ 2 + 0.7 * (R * Sin((J + K / 60) * PI / 30))), vbYellow

'画秒针

Line (W \ 2, H \ 2)-(W \ 2 + 0.9 * (R * Cos(K * PI / 30)), H \ 2 + 0.9 * (R * Sin(K * PI / 30))), vbRed

K = K + 1

If K 360 Then K = K Mod 360

lbTime.Caption = Time

End Sub


网站名称:vb点虐 做闹钟步骤 vb添加时钟控件
链接URL:http://myzitong.com/article/ddiiceh.html