我急需有高手教我做VB指针式时钟 我在做Vb指针式始时钟,但是有些地方不懂,需要高手教我 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 Form.Line方法画线。没什么难的。搞清楚坐标关系就行了,参考初中三角函数内容。 借鉴这个现成的示例代码就行了.有截图,不用注册,直接下载:http://www.anqn.com/delphi/6/800.shtmlE_Clock 仿真时钟 那个是DELPHI的,这两个VB的:http://www.anqn.com/vb/159/5870.shtml纯VB实现的透明时钟(绝无控件)http://www.anqn.com/vb/159/4442.shtmlVista界面精美时钟控件源代码 Ver 1.0 Option ExplicitConst π = 3.14159127Dim XS, YS, radDim 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 = TrueEnd 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) + YSEnd SubPrivate Function clock(X) rad = π / 180 clock = X * radEnd Function 应该不难.先做个时钟底图放到PICTUREBOX上,然后用LINETO(画线)\FLOODFILL(填色)等函数根据时间变化画时针.用TIMER控件控制时间变化. 猴哥的代码有一点小小瑕疵,改一下: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 = TrueEnd Sub 资源推荐:代码自动生成、Com开发、串行化反串行化、UI等太多了 VB与Oracle数据库的问题 sstab控件与tabstrip控件有何区别呀?这种情况我应该用哪种控件呢? 如何避免子函数同时被2个函数调用? 如何设置datareport控件的,DataMember 属性?50分!大侠帮个忙! 怎样才能在Combobox下来列表中选中一项时触发一个事件?onchange怎么不能响应这个动作? 关于DDE的控件制作的问题 VB之道 怎样判断MIDI文件已播放完毕,怎样循环播放? '''' 图像处理中,怎么做细线化这部份? VB如何预览、打印
http://www.anqn.com/delphi/6/800.shtml
E_Clock 仿真时钟
http://www.anqn.com/vb/159/5870.shtml
纯VB实现的透明时钟(绝无控件)
http://www.anqn.com/vb/159/4442.shtml
Vista界面精美时钟控件源代码 Ver 1.0
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
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