我在做Vb指针式始时钟,但是有些地方不懂,需要高手教我

解决方案 »

  1.   

    Form.Line方法画线。没什么难的。搞清楚坐标关系就行了,参考初中三角函数内容。
      

  2.   

    借鉴这个现成的示例代码就行了.有截图,不用注册,直接下载:
    http://www.anqn.com/delphi/6/800.shtml
    E_Clock 仿真时钟
      

  3.   

    那个是DELPHI的,这两个VB的:
    http://www.anqn.com/vb/159/5870.shtml
    纯VB实现的透明时钟(绝无控件)
    http://www.anqn.com/vb/159/4442.shtml
    Vista界面精美时钟控件源代码 Ver 1.0
      

  4.   


    Option ExplicitConst π = 3.14159127
    Dim XS, YS, rad
    Dim ab%, CNT%, a!, b!, W!, X!, Y!, Z!, C!, D!, E!, F!, TX$Private Sub Form_Load()
            Me.AutoRedraw = True
            XS = Width / 2
            YS = (Height / 2) - 120
            Font.Name = "Courier New"
            For ab = 0 To 359 Step 30
                a = Sin(clock(ab))
                b = -(Cos(clock(ab)))
                If ab = 0 Then CNT = 360 Else CNT = ab
                TX = Trim(Int((CNT) / 30))
                Line ((a * 1000) + XS, (b * 1000) + YS)-((a * 900) + XS, (b * 900) + YS), RGB(0, 0, 0)
                CurrentX = (a * 1200) + XS - (TextWidth(TX$) / 2)
                CurrentY = (b * 1200) + YS - (TextHeight(TX$) / 2)
                Print TX$
            Next ab
            Line1.X1 = XS
            Line1.Y1 = YS
            Line2.X1 = XS
            Line2.Y1 = YS
            Line3.X1 = XS
            Line3.Y1 = YS
            Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2
            Timer1.Interval = 500
            Timer1.Enabled = True
    End SubPrivate Sub Timer1_Timer()
            W = Timer
            X = W / 120
            Y = W * 6
            Z = W / 10
            a = Sin(clock(X))
            b = -(Cos(clock(X)))
            Line1.X2 = (a * 600) + XS
            Line1.Y2 = (b * 600) + YS
            C = Sin(clock(Y))
            D = -(Cos(clock(Y)))
            Line3.X2 = (C * 800) + XS
            Line3.Y2 = (D * 800) + YS
            E = Sin(clock(Z))
            F = -(Cos(clock(Z)))
            Line2.X2 = (E * 800) + XS
            Line2.Y2 = (F * 800) + YS
    End SubPrivate Function clock(X)
            rad = π / 180
            clock = X * rad
    End Function
      

  5.   

    应该不难.先做个时钟底图放到PICTUREBOX上,然后用LINETO(画线)\FLOODFILL(填色)等函数根据时间变化画时针.用TIMER控件控制时间变化.
      

  6.   

    猴哥的代码有一点小小瑕疵,改一下:Private Sub Form_Load()
            Me.AutoRedraw = True
            XS = Width / 2
            YS = (Height / 2) - 120
            Font.Name = "Courier New"
            For ab = 0 To 359 Step 30
                a = Sin(clock(ab))
                b = -(Cos(clock(ab)))
                If ab = 0 Then CNT = 360 Else CNT = ab
                TX = Trim(Int((CNT) / 30))
                Line ((a * 1000) + XS, (b * 1000) + YS)-((a * 900) + XS, (b * 900) + YS), RGB(0, 0, 0)
                CurrentX = (a * 1200) + XS - (TextWidth(TX$) / 2)
                CurrentY = (b * 1200) + YS - (TextHeight(TX$) / 2)
                Print TX$
            Next ab
            Line1.X1 = XS
            Line1.Y1 = YS
            Line2.X1 = XS
            Line2.Y1 = YS
            Line3.X1 = XS
            Line3.Y1 = YS
            Timer1_Timer    '指针位置初始化
            
            Me.Move (Screen.Width - Me.Width) \ 2, (Screen.Height - Me.Height) \ 2
            Timer1.Interval = 500
            Timer1.Enabled = True
    End Sub