Một số hàm về cộng trừ thời gian trong VB6
Tham khảo từ caulacbovb.com
Private Sub Form_Load() Dim t1 As Date Dim t2 As Date t1 = Format("02/12/2010 235958", "dd/MM/yyyy hhmmss") t2 = Format("010000", "hhmmss") t1 = t1 + t2 MsgBox Format(t1, "dd/MM/yyyy hhmmss") t2 = Format("020000", "hhmmss") MsgBox Format(t1 - t2, "dd/MM/yyyy hhmmss") End Sub
Dim s As String s = Format("02/12/2010 115958 CH", "dd/mm/yyyy hhmmss AMPM") Me.Caption = DateAdd("h", 2, s)
Private Sub Command1_Click() Dim T1 As Date 'T1 = Now '(Now o' Ðây là lúc mo'i nhân phòng Kara) ' vd lúc Ðó ghi là T1 = "11/22/2011 183817" ' sau vài tiê'ng hát hò... ' Bây gio' tính tiên, Lâ'y (Now hiên tai - T1) Dim S S = Format(Now - T1, "hhnn") ' Sô' phút Ðôi ra thâp phân là chia cho 60, sô 1 o' sau là lâ'y 1 sô' le~ Dim Ptp! Ptp = FormatNumber(Minute(S) / 60, 1) ' ghép lai vo'i Gio', ta nhân 10 MsgBox S & " = " & Format(S, "h," & Ptp * 10) End Sub