VB程序 --时钟

来源:百度知道 编辑:UC知道 时间:2024/07/07 21:32:11
用VB编写一个简单的时钟,能运行就可以哈!麻烦大侠们写下详细代码和截图哈,谢谢了!

以前写过一个,如果不想看下面的代码就直接跳到最后吧。'添加计时器tmr,图片容器pic,然后添加如下代码:Public originX, originY As DoublePublic i As DoublePublic s, m, h As IntegerConst stepN As Double = 6 * 3.141592627 / 180 '这是后面要用到的步长Private Declare Function SetWindowPos Lib "user32" (ByVal hwnd As Long, ByVal hWndInsertAfter As Long, ByVal x As Long, ByVal y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) As LongConst HWND_TOPMOST = -1Const SWP_SHOWWINDOW = &H40'窗体载入时就画好时钟界面,包括时针、分针、秒针Private Sub Form_Load() Dim angleN As Double Dim counts As Integer 'originX,originY为时钟中心 originX = pic.Width / 2 originY = pic.Height / 2 '画两个圆表示时钟的外边缘 pic.Circle (originX, originY), 1400 pic.Circle (originX, originY), 1500 '画时钟中心 pic.Circle (originX, originY), 40 pic.Circle (originX, originY), 70 pic.Circle (originX, originY), 100 For angleN = 0 To 3.134952627 * 2 Step stepN If counts Mod 5 = 0 Then pic.Line (originX + 1200 * Cos(angleN), originY + 1200 *