vb点虐 时钟控件的简单介绍-成都创新互联网站建设

关于创新互联

多方位宣传企业产品与服务 突出企业形象

公司简介 公司的服务 荣誉资质 新闻动态 联系我们

vb点虐 时钟控件的简单介绍

用VB点虐 做一个时间计时器

'添加一个label标签名字label1 用来显示时间

成都网络公司-成都网站建设公司创新互联公司十多年经验成就非凡,专业从事成都网站设计、成都做网站,成都网页设计,成都网页制作,软文营销1元广告等。十多年来已成功提供全面的成都网站建设方案,打造行业特色的成都网站建设案例,建站热线:18980820575,我们期待您的来电!

'再添加一个timer控件 名字timer1 interval属性=1000 用来计时

'窗体添加代码

Dim t As Date '用来记录时间

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As _

System.EventArgs) Handles Timer1.Tick

t = t.AddSeconds(1)

Label1.Text = "登录时间:" t.TimeOfDay.ToString

End Sub

vb点虐 中datetimepicker控件的时间格式问题

还要设置Format 为 : Custom

用的时候用DateTimePicker1.Text 不要用value

下面是我随便用了两个DateTimePicker和一个button一个textbox演示了一下的代码,你根据自己的需要调试DateTimePicker风格

------------------------------------------------

Public Class Form1

Inherits System.Windows.Forms.Form

#Region

Public Sub New()

MyBase.New()

InitializeComponent()

End Sub

Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)

If disposing Then

If Not (components Is Nothing) Then

components.Dispose()

End If

End If

MyBase.Dispose(disposing)

End Sub

Private components As System.ComponentModel.IContainer

Friend WithEvents DateTimePicker1 As System.Windows.Forms.DateTimePicker

Friend WithEvents Button1 As System.Windows.Forms.Button

Friend WithEvents TextBox1 As System.Windows.Forms.TextBox

Friend WithEvents DateTimePicker2 As System.Windows.Forms.DateTimePicker

System.Diagnostics.DebuggerStepThrough() Private Sub InitializeComponent()

Me.DateTimePicker1 = New System.Windows.Forms.DateTimePicker

Me.Button1 = New System.Windows.Forms.Button

Me.TextBox1 = New System.Windows.Forms.TextBox

Me.DateTimePicker2 = New System.Windows.Forms.DateTimePicker

Me.SuspendLayout()

'

'DateTimePicker1

'

Me.DateTimePicker1.AllowDrop = True

Me.DateTimePicker1.CustomFormat = "yyyy-MM-dd"

Me.DateTimePicker1.Format = System.Windows.Forms.DateTimePickerFormat.Custom

Me.DateTimePicker1.Location = New System.Drawing.Point(56, 24)

Me.DateTimePicker1.Name = "DateTimePicker1"

Me.DateTimePicker1.ShowUpDown = True

Me.DateTimePicker1.Size = New System.Drawing.Size(160, 19)

Me.DateTimePicker1.TabIndex = 0

'

'Button1

'

Me.Button1.Location = New System.Drawing.Point(144, 128)

Me.Button1.Name = "Button1"

Me.Button1.TabIndex = 1

Me.Button1.Text = "Button1"

'

'TextBox1

'

Me.TextBox1.Location = New System.Drawing.Point(136, 72)

Me.TextBox1.Name = "TextBox1"

Me.TextBox1.TabIndex = 2

Me.TextBox1.Text = "TextBox1"

'

'DateTimePicker2

'

Me.DateTimePicker2.CustomFormat = "yyyy-MM-dd"

Me.DateTimePicker2.Format = System.Windows.Forms.DateTimePickerFormat.Custom

Me.DateTimePicker2.Location = New System.Drawing.Point(40, 160)

Me.DateTimePicker2.Name = "DateTimePicker2"

Me.DateTimePicker2.Size = New System.Drawing.Size(120, 19)

Me.DateTimePicker2.TabIndex = 3

'

'Form1

'

Me.AutoScaleBaseSize = New System.Drawing.Size(5, 12)

Me.ClientSize = New System.Drawing.Size(292, 273)

Me.Controls.Add(Me.DateTimePicker2)

Me.Controls.Add(Me.TextBox1)

Me.Controls.Add(Me.Button1)

Me.Controls.Add(Me.DateTimePicker1)

Me.Name = "Form1"

Me.Text = "Form1"

Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

TextBox1.Text = DateTimePicker1.Text

End Sub

End Class

----------------------------------------------------------

我的操作系统和点虐 都是日文的,注释的东西我删除了,主要看代码就好了

这段代码你可以建一个空的解决方案,完全复制到里面去

VB点虐 窗体程序的time控件,可以识别到的最小时间差是多少纳秒 ?

VB有现成的函数:

DateDiff(格式,日期1,日期2)

如今天到2010-5-1 8:00:00的时间差,代码:

DateDiff("yyyy",Now,#2010-5-1 8:00:00#) '还有几(整)年

DateDiff("q",Now,#2010-5-1 8:00:00#) '还有几(整)季度

DateDiff("m",Now,#2010-5-1 8:00:00#) '还有几(整)月

DateDiff("d",Now,#2010-5-1 8:00:00#) '还有几(整)天

DateDiff("ww",Now,#2010-5-1 8:00:00#) '还有几(整)周

DateDiff("h",Now,#2010-5-1 8:00:00#) '还有几(整)小时

DateDiff("n",Now,#2010-5-1 8:00:00#) '还有几(整)分钟

DateDiff("s",Now,#2010-5-1 8:00:00#) '还有几(整)秒


文章标题:vb点虐 时钟控件的简单介绍
转载来于:http://kswsj.cn/article/ddigpgj.html

其他资讯