大橙子网站建设,新征程启航
为企业提供网站建设、域名注册、服务器等服务
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#) '还有几(整)秒
Private Declare Function GetCursorPos Lib "user32" (ByRef lpPoint As POINTAPI) As Long '全屏坐标声明
Private Declare Function ScreenToClient Lib "user32.dll" (ByVal hwnd As Int32, ByRef lpPoint As POINTAPI) As Int32 '窗口坐标声明
Private Structure POINTAPI '声明坐标变量
Public x As Int32 '声明坐标变量为32位
Public y As Int32 '声明坐标变量为32位
End Structure
'以上是声明部分
'以下是窗口部分
Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer1.Tick '用时钟控件来取坐标,窗口上放个Timer组件,Enabled为允许,周期为10到100毫秒均可
Dim P As POINTAPI '声明坐标变量
Dim xx, yy '声明转换要用到的变量
GetCursorPos(P) '获取鼠标在屏幕中的位置
ScreenToClient(Me.Handle.ToInt32, P) '转换为本窗体的坐标
xx = P.x.ToString '把X转换成能显示到文本框的字符串格式
yy = P.y.ToString '把Y转换成能显示到文本框的字符串格式
TextBox1.Text = xx + "和" + yy '文本框的内容为X坐标和Y坐标
End Sub
1、程序加载时操作: Private Sub Form_Load() '窗体加载时自动进行
Timer1.Interval = 1000 ‘设置计时周期为1秒注意默认计时单位为毫秒,即1/1000秒
2、定义一个时间变量。可以某控件的Caption属性代替,如Label12.Caption
3、拖放timer控件到程序界面上
4、设置倒计时:双击时钟控件,输入计时规则,如Label12.Caption = Label12.Caption + 1
5、设置当时间值达到某一条件的时候应采取的方法(即动作)。可以用if语句。如if Label12.Caption =60,then Unload Form1,注意块if语句与行if语句的区别
以下是例子:
Private Sub Form_Load() '窗体加载时自动进行以下操作
Timer1.Interval = 1000 '计时频率设为1秒
end sub
Private Sub Timer1_Timer()
Label12.Caption = Label12.Caption - 1 '以秒计时
End Sub
Private Sub CommandSure_Click()
if Label12.Caption =
s = MsgBox("确认提交,取消重填!", 1, "提示信息") '弹出对话框
If s = 1 Then
f = MsgBox("提交信息成功,请点击确认退出系统", 0, "")
Unload Form1 '窗体关闭
Else
Load Form1 '重新初始化
Form1.Enabled = True '允许重填
Timer1.Enabled = True '继续计时
CommandSure.Enabled = True '确定按钮可用
end if
end sub
还要设置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
----------------------------------------------------------
我的操作系统和.net都是日文的,注释的东西我删除了,主要看代码就好了
这段代码你可以建一个空的解决方案,完全复制到里面去