怎样连写日期
怎样连写日期 例如:将2006-08-29 19:43:52 连写为 194352
Private Sub Command1_Click() Dim datetime As String datetime = Mid(Date$, 1, 4) & Mid(Date$, 6, 2) & Mid(Date$, 9, 2) & Mid(Time$, 1, 2) & Mid(Time$, 4, 2) & Mid(Time$, 7, 2) Text1 = datetime End Sub
用REPLACE函数即可。 示例代码如下: Dim s1 As String s1 = "2006-08-29 19:43:52" s1 = Replace(s1, "-", "") s1 = Replace(s1, " ", "") s1 = Replace(s1, ":", "") MsgBox s1 如果是将一个Date类型的变量以固定格式输出,那就更简单了,用FORMAT函数即可。示例如下: Dim t1 As Date, s1 As String t1 = Now s1 = Format(t1, "yyyymmddhhmmss") MsgBox s1
详细代码如下,工程文件在附件中,均已经有详细注释 --------------------此行以下为代码------------------------- Public Class Time Private Sub BCONFIRM_Click(ByVal sender As System。
Object, ByVal e As System。EventArgs) Handles BCONFIRM。Click '按下Comfirm按钮 Dim Timenow As Date '声明Timenow为Date类型 Timenow = Now() '获取当前时间 LabelTime。
Text = Format(Timenow, "yyyy-MM-dd hh:mm:ss") '按照yyyy-MM-dd hh:mm:ss形式格式化字串,并在LabelTime控件中显示 LabelTimeE。
Text = Format(Timenow, "yyyyMMddhhmmss") '按照yyyyMMddhhmmss形式格式化字串LabelTimeE控件中显示 End Sub End Class --------------------此行以上为代码-------------------------。