vb.net画表针的简单介绍
用VB编一个钟表,表针运动程序怎么编?
这个比较麻烦,我曾经写过这么个程序片段,现在贴上来,代码比较复杂
创新互联于2013年创立,是专业互联网技术服务公司,拥有项目网站建设、网站制作网站策划,项目实施与项目整合能力。我们以让每一个梦想脱颖而出为使命,1280元青神做网站,已为上家服务,为青神各地企业和个人服务,联系电话:13518219792
Shape1是时钟的一个框,是Shape控件,设置 Height 1455 Width 1575
LineHour,LineMinute,LineSecond分别为时,分,秒针,为Line控件
Label3,Label6,Label9,Label12为Label控件,分别为3.6.912点的显示数字
再画个Timer控件,Interval设置为1000
以上控件位置随便放,代码里调整
Form_Load事件里写
Shape1.Top = 100
Shape1.Left = Me.Width - 1800
LineHour.X1 = Shape1.Left + Shape1.Width / 2
LineHour.Y1 = Shape1.Top + Shape1.Height / 2
LineMinute.X1 = Shape1.Left + Shape1.Width / 2
LineMinute.Y1 = Shape1.Top + Shape1.Height / 2
LineSecond.X1 = Shape1.Left + Shape1.Width / 2
LineSecond.Y1 = Shape1.Top + Shape1.Height / 2
Label3.Left = Shape1.Left + Shape1.Width - Label3.Width - 200
Label3.Top = Shape1.Top + (Shape1.Height - Label3.Height) / 2
Label6.Left = Shape1.Left + (Shape1.Width - Label6.Width) / 2
Label6.Top = Shape1.Top + Shape1.Height - Label6.Height + 20
Label9.Left = Shape1.Left + 200
Label9.Top = Shape1.Top + (Shape1.Height - Label9.Height) / 2
Label12.Left = Shape1.Left + (Shape1.Width - Label12.Width) / 2
Label12.Top = Shape1.Top + 100
Timer事件里写
'利用Label显示数字
If Shape1.Visible True Then Shape1.Visible = True
If LineHour.Visible True Then LineHour.Visible = True
If LineMinute.Visible True Then LineMinute.Visible = True
If LineSecond.Visible True Then LineSecond.Visible = True
If Label3.Visible True Then Label3.Visible = True
If Label6.Visible True Then Label6.Visible = True
If Label9.Visible True Then Label9.Visible = True
If Label12.Visible True Then Label12.Visible = True
Dim cx As Single, cy As Single '圆心坐标
cx = Shape1.Left + Shape1.Width / 2
cy = Shape1.Top + Shape1.Height / 2
'利用Line控件绘制指针
LineSecond.X2 = LineSecond.X1 + Sin(CLng(Second(Now)) / 60 * 2 * pi) * 480
LineSecond.Y2 = LineSecond.Y1 - Cos(CLng(Second(Now)) / 60 * 2 * pi) * 480
LineMinute.X2 = LineMinute.X1 + Sin(CLng(Minute(Now)) / 60 * 2 * pi) * 360
LineMinute.Y2 = LineMinute.Y1 - Cos(CLng(Minute(Now)) / 60 * 2 * pi) * 360
LineHour.X2 = LineHour.X1 + Sin((CLng(Hour(Now)) + CLng(Minute(Now)) / 60) / 12 * 2 * pi) * 240
LineHour.Y2 = LineHour.Y1 - Cos((CLng(Hour(Now)) + CLng(Minute(Now)) / 60) / 12 * 2 * pi) * 240
'利用Line方法绘制刻度
Me.Line (cx + 250, cy - 433.012701892219)-(cx + 300, cy - 519.615242270663)
Me.Line (cx + 433.012701892219, cy - 250)-(cx + 519.615242270663, cy - 300)
Me.Line (cx + 433.012701892219, cy + 250)-(cx + 519.615242270663, cy + 300)
Me.Line (cx + 250, cy + 433.012701892219)-(cx + 300, cy + 519.615242270663)
Me.Line (cx - 250, cy + 433.012701892219)-(cx - 300, cy + 519.615242270663)
Me.Line (cx - 433.012701892219, cy + 250)-(cx - 519.615242270663, cy + 300)
Me.Line (cx - 433.012701892219, cy - 250)-(cx - 519.615242270663, cy - 300)
Me.Line (cx - 250, cy - 433.012701892219)-(cx - 300, cy - 519.615242270663)
VB.net中如何画图?
VB.net与VB不同。
VB.net已经有专门绘图的类。
可以定义笔刷然后用Drawing类中的方法绘制。
Private Sub DrawEllipse()
Dim myPen As New System.Drawing.Pen(System.Drawing.Color.Red)
Dim formGraphics as System.Drawing.Graphics
formGraphics = Me.CreateGraphics()
formGraphics.DrawEllipse(myPen, New Rectangle(0,0,200,300))
myPen.Dispose()
formGraphics.Dispose()
End Sub
Private Sub DrawRectangle()
Dim myPen As New System.Drawing.Pen(System.Drawing.Color.Red)
Dim formGraphics as System.Drawing.Graphics
formGraphics = Me.CreateGraphics()
formGraphics.DrawRectangle(myPen, New Rectangle(0,0,200,300))
myPen.Dispose()
formGraphics.Dispose()
End Sub
如何用VB.NET调用excel的画图命令,即用.NET得到一组点坐标后,调用excel根据点画出曲线图并显示在VB.NET里
你可以通过用VB.net控制excel,让excel生成曲线图,然后利用excelVBA将图输出,最后导入到VB.net就可以了。
名称栏目:vb.net画表针的简单介绍
当前地址:http://ybzwz.com/article/hecdci.html