给大家分享一个动态时钟的代码Option ExplicitD
vb6.0吧
全部回复
仅看楼主
level 11
给大家分享一个动态时钟的代码Option ExplicitDim r, x, y, NumSize As Single, n, c, lastsecond As IntegerConst PI = 3.14
15926535897
9Private Sub Form_Load()Form1.AutoRedraw = TrueForm1.BackColor = RGB(100, 100, 150)Form1.Top = 30Form1.Width = 9000Form1.Height = 8600Label1.Caption = Str(Year(Now)) + "年" + Str(Month(Now)) + "月" + Str(Day(Now)) + "日"Timer1.Interval = 853End SubPrivate Sub Form_Resize()Form1.Caption = "waiting..."r = IIf(Form1.Width > Form1.Height, Form1.Height, Form1.Width) / 2 * 0.9x = Form1.Width / 2.05y = Form1.Height / 2.1NumSize = 10 * r / 2900ClsForm1.FontSize = NumSize * 3CurrentX = x - Form1.TextWidth("-lyxue's DIY-") / 2CurrentY = y - Form1.TextHeight("-lyxue's DIY-") * 1.5Print "-lyxue's DIY-"CurrentX = x - Form1.TextWidth("-lyxue's DIY-") / 2CurrentY = CurrentY + Form1.TextHeight("[email protected]") / 4Print "[email protected]"End SubPrivate Sub Timer1_Timer()If lastsecond = Second(Now) Then Exit Sub Else lastsecond = Second(Now)ClsFor n = 1 To 60If n Mod 5 = 0 ThenForm1.ForeColor = RGB(255, 98, 21)Form1.FontSize = NumSize * 2Form1.FontBold = TrueCurrentX = x + Sin(n * PI / 30) * r - Form1.TextWidth(n & " ") / 2CurrentY = y - Cos(n * PI / 30) * r - Form1.TextWidth(n) / 2Print n / 5ElseForm1.ForeColor = vbWhiteForm1.FontSize = NumSizeForm1.FontBold = FalseCurrentX = x + Sin(n * PI / 30) * r - Form1.TextWidth(n & " ") / 2CurrentY = y - Cos(n * PI / 30) * r - Form1.TextWidth(n) / 2Print nEnd IfNextForm1.ForeColor = RGB(255, 98, 21)Form1.FontSize = NumSize * 1.8Form1.FontBold = TrueFor n = 0 To 5CurrentX = x + Sin((Hour(Now) * 60 + Minute(Now)) * PI / 360) * r * 0.09 * n - Form1.TextWidth(n) / 2CurrentY = y - Cos((Hour(Now) * 60 + Minute(Now)) * PI / 360) * r * 0.09 * n - Form1.TextWidth(n) / 2Print Hour(Now)NextForm1.ForeColor = RGB(213, 213, 80)Form1.FontSize = NumSize * 1.3For n = 0 To 8CurrentX = x + Sin((Minute(Now) * 60 + Second(Now)) * PI / 1800) * r * 0.09 * n - Form1.TextWidth(n) / 2CurrentY = y - Cos((Minute(Now) * 60 + Second(Now)) * PI / 1800) * r * 0.09 * n - Form1.TextWidth(n) / 2Print Minute(Now)NextForm1.ForeColor = vbWhiteForm1.FontSize = NumSize * 0.8Form1.FontBold = FalseFor n = -2 To 10CurrentX = x + Sin(Second(Now) * PI / 30) * r * 0.09 * n - Form1.TextWidth(n) / 3CurrentY = y - Cos(Second(Now) * PI / 30) * r * 0.09 * n - Form1.TextHeight(n) / 3Print Second(Now)NextForm1.Caption = TimeEnd Sub
2019年05月08日 13点05分 1
level 11
窗体只需要加一个timer和一个label就可以
2019年05月08日 13点05分 2
level 11
2019年05月08日 13点05分 3
level 1
编辑器直接识别不了
2022年03月28日 06点03分 4
1