请教怎么对一个date形变量付置
请问如何对一个date形变量付置?
Dim Start_time As Date
Start_time = "07/10/07 11:12:13"
如果我想把月份改为4月,应该如何操作?
------解决方案--------------------
Start_time = DateAdd("m", 4-Month(Start_time) , Start_time)
------解决方案--------------------
Option Explicit
Private Sub Command1_Click()
Dim date1 As Date
date1 = Date
'将下面的月份部分随意修改就行
MsgBox Format(Year(date1), "0000") & "/" & Format(Month(date1), "00") & "/" & Format(Day(date1), "00")
End Sub
------解决方案--------------------
窗体上放 6 个 ComboBox, 分别是年、月、日、时、分、秒。做成数组方式。
Private Sub Combo1_Click(Byval Index As Integer)
txtDate = Combo(0) & "-" combo(1) & "-" & combo(2) & " " & combo(3) & ":" & combo(4) & ":" & combo(5)
Start_Time = txtDate
EndSub
当然,最简单的是用 DTPicker 控件:
Private Sub DTPicker1_Click()
Start_Time = DTPicker1.Value
End Sub
------解决方案--------------------
应该用 2 楼的方法
------解决方案--------------------
2楼正解,就用加很方便的。
------解决方案--------------------
似乎VB中的Date类型不支持?!
可以用string来代替
Dim Start_time As Date
Start_time = "07/10/07 11:12:13"
如果我想把月份改为4月,应该如何操作?
------解决方案--------------------
Start_time = DateAdd("m", 4-Month(Start_time) , Start_time)
------解决方案--------------------
Option Explicit
Private Sub Command1_Click()
Dim date1 As Date
date1 = Date
'将下面的月份部分随意修改就行
MsgBox Format(Year(date1), "0000") & "/" & Format(Month(date1), "00") & "/" & Format(Day(date1), "00")
End Sub
------解决方案--------------------
窗体上放 6 个 ComboBox, 分别是年、月、日、时、分、秒。做成数组方式。
Private Sub Combo1_Click(Byval Index As Integer)
txtDate = Combo(0) & "-" combo(1) & "-" & combo(2) & " " & combo(3) & ":" & combo(4) & ":" & combo(5)
Start_Time = txtDate
EndSub
当然,最简单的是用 DTPicker 控件:
Private Sub DTPicker1_Click()
Start_Time = DTPicker1.Value
End Sub
------解决方案--------------------
应该用 2 楼的方法
------解决方案--------------------
2楼正解,就用加很方便的。
------解决方案--------------------
似乎VB中的Date类型不支持?!
可以用string来代替