none
vb6.0下写了个时钟程序 RRS feed

  • 常规讨论

  •  

    如果无法运行,把第12行代码中的“华文行楷”改为“宋体”就行了

    '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\ 

    'lyxuess @ qq.com

    Option Explicit

    Dim WithEvents timer1 As Timer

    Dim r, x, y, NumSize As Single, n, c, lastsecond As Integer

    Const PI = 3.14159265358979

     

    Private Sub Form_Load()

    Set timer1 = Controls.Add("vb.timer", "timer1")

    Me.AutoRedraw = True

    Me.BackColor = RGB(100, 100, 150)

    Me.Width = Screen.Width * 0.9: Me.Height = Screen.Height * 0.9

    Me.Move (Screen.Width - Me.Width) / 2, (Screen.Height - Me.Height) / 2

    Me.FontName = "华文行楷"

    timer1.Interval = 853

    End Sub

     

    Private Sub Form_Resize()

    Me.Caption = "waiting..."

    r = IIf(Me.Width > Me.Height, Me.Height, Me.Width) / 2 * 0.9

    x = Me.Width / 2.05

    y = Me.Height / 2.1

    NumSize = 10 * r / 2900

    Cls

    Me.FontSize = NumSize * 3

    CurrentX = x - Me.TextWidth("-lyxue's DIY-") / 2

    CurrentY = y - Me.TextHeight("-lyxue's DIY-") * 1.5

    Print "-lyxue's DIY-"

    CurrentX = x - Me.TextWidth("-lyxue's DIY-") / 2

    CurrentY = CurrentY + Me.TextHeight("lyxue@139.com") / 4

    Print "lyxue@139.com"

    End Sub

     

    Private Sub Timer1_Timer()

    If lastsecond = Second(Now) Then Exit Sub Else lastsecond = Second(Now)

    Cls

    For n = 1 To 60

    If n Mod 5 = 0 Then

    Me.ForeColor = RGB(255, 98, 21)

    Me.FontSize = NumSize * 2

    Me.FontBold = True

    CurrentX = x + Sin(n * PI / 30) * r - Me.TextWidth(n & " ") / 2

    CurrentY = y - Cos(n * PI / 30) * r - Me.TextWidth(n) / 2

    Print n / 5

    Else

    Me.ForeColor = vbWhite

    Me.FontSize = NumSize

    Me.FontBold = False

    CurrentX = x + Sin(n * PI / 30) * r - Me.TextWidth(n & " ") / 2

    CurrentY = y - Cos(n * PI / 30) * r - Me.TextWidth(n) / 2

    Print n

    End If

    Next

    Me.ForeColor = RGB(255, 98, 21)

    Me.FontSize = NumSize * 1.8

    Me.FontBold = True

    For n = 0 To 5

    CurrentX = x + Sin((Hour(Now) * 60 + Minute(Now)) * PI / 360) * r * 0.09 * n - Me.TextWidth(n) / 2

    CurrentY = y - Cos((Hour(Now) * 60 + Minute(Now)) * PI / 360) * r * 0.09 * n - Me.TextWidth(n) / 2

    Print Hour(Now)

    Next

    Me.ForeColor = RGB(213, 213, 80)

    Me.FontSize = NumSize * 1.3

    For n = 0 To 8

    CurrentX = x + Sin((Minute(Now) * 60 + Second(Now)) * PI / 1800) * r * 0.09 * n - Me.TextWidth(n) / 2

    CurrentY = y - Cos((Minute(Now) * 60 + Second(Now)) * PI / 1800) * r * 0.09 * n - Me.TextWidth(n) / 2

    Print Minute(Now)

    Next

    Me.ForeColor = vbWhite

    Me.FontSize = NumSize * 0.8

    Me.FontBold = False

    For n = -2 To 10

    CurrentX = x + Sin(Second(Now) * PI / 30) * r * 0.09 * n - Me.TextWidth(n) / 2

    CurrentY = y - Cos(Second(Now) * PI / 30) * r * 0.09 * n - Me.TextHeight(n) / 2

    Print Second(Now)

    Next

    Me.Caption = Time

    End Sub

    '\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\

    2010年7月11日 12:04