vb問題,如何比較時間的大小,VB問題,如何比較時間的大小

時間 2022-02-04 07:55:05

1樓:

private sub command1_click()dim 上班時間 as date, 下班時間 as date上班時間 = "08:30"

下班時間 = "17:30"

if now > 0.5 then

if now < 下班時間 then

msgbox "下班時間未到,請不要早退!"

else

msgbox "平平安安又一天,明天見!"

end if

else

if now > 上班時間 then

msgbox "上班時間已過,你遲到了。以後要注意。"

else

msgbox "安全第一,預防為主。歡迎你回到工作崗位。"

end if

end if

end sub

2樓:匿名使用者

if format(打卡時間,"hh:mm") > "08:04" then print "遲到了!"

if format(打卡時間,"hh:mm") < "17:30" then print "還未到下班時間,不能打卡!"

3樓:

'上班時間

if time > "08:30" then print "遲到了!"

'下班時間

if time < "17:30" then print "還未到下班時間,不能打卡!"

vb中怎樣比較兩個日期的大小

4樓:

dim later

date1 = "2010-02-02"

date2 = "2009-01-01"

if datevalue(date1) > datevalue(date2) then

later = cdate(date1)

else

later = cdate(date2)

end if

msgbox "較大的日期是" & later

5樓:匿名使用者

date1 = "2010-10-10 12:14"

date2 = "2011-2-3"

if datediff("d", cdate(date1), cdate(date2)) < 0 then

msgbox date1 & "大"

else

msgbox date2 & "大"

end if

怎樣在vb中比較兩個日期大小

6樓:匿名使用者

兩個日期間用format(date(),"yyyy-mm-dd")初始化後,直接用大小於號比較就行了。

7樓:匿名使用者

日期比較其實直接比較2個字串就行了

dim a as string

dim b as string

a="日期1"

b="日期2"

if a>b then

msgbox("過期")

else

msgbox("沒過期")

end if

8樓:匿名使用者

我一般用clng來比較例如

if clng(date1)>clng(date2) then'.....

endif

9樓:灰原哀柯南君蘭

日期運算子與日期表示式

日期表示式是用日期運算子「+」或「-」用算數表示式、日期型常量、日期型變數、日期函式等連線起來的式子。有一下三種運算方式:

①兩個日期型資料相減,其結果是一個數值型資料(相差的天數)②日期型資料加上天數,其結果為一個日期型資料③日期型資料減去天數,其結果為一個日期型資料

10樓:匿名使用者

datediff

用法不多說了。

下面是參考網頁。

vb日期比較大小問題

11樓:匿名使用者

用datediff判斷兩個時間的差的正負就最簡單了比如:if datediff("d",now,#2009/06/30#)>0 thena

12樓:匿名使用者

update 表名 set 欄位名='是' where datediff(day,時間1,時間2)<10

13樓:匿名使用者

datediff("d",時間1,時間2)<10

vb兩個字串型別的時間,怎樣比較大小呢?

14樓:匿名使用者

可以先用字串操作,將時、分、秒的數分開,再將時間計算成秒,即總時間=時×3600+分×60+秒,這樣總時間1-總時間2就可以得到秒錶示的差值,同樣可以反過來用將差值表示為時:分:秒的形式。

15樓:匿名使用者

1、把它們轉換成時間格式比較。

2、假設你的時間格式=a:b:c

用if else 巢狀分別判斷3部分的大小關係得出相應結果。

16樓:匿名使用者

private sub command1_click()

dim t1 as string, t2 as string

t1 = "5:0:11"

t2 = "3:0:11"

if datediff("s", "2000-1-1 " & t1, "2000-1-1 " & t2) > 0 then

msgbox "t1大"

elseif datediff("s", "2000-1-1 " & t1, "2000-1-1 " & t2) > 0 then

msgbox "t2大"

else

msgbox "相同"

end if

end sub

'--- 你的時間 怎麼會出現 52點和25點呢? 我這段** 僅在 時間格式的正確的情況下 才有效

你可以加個 判斷 判斷下 t1 t2 的 時 分 秒 這3個位置 是否是 正確的時間資料

17樓:匿名使用者

if cdate("13:00:00")>cdate("12:00:00") then

msgbox"超時"

end if

vb 整除的問題,VB 整除的問題

private sub command1 click dim n as integer,sum as longn cint text1.text if n 1000 or n 1 thenmsgbox 輸入數值超範圍 exit sub end if for i 0 to n step 3sum su...

vb的問題 5,關於vb的小問題

首先timer1在屬性那設定interval 設為100,表示100毫秒 label1屬性的caption設為 上機測試。dim step as integer private sub command1 click trueend sub private sub command2 click fla...

VB程式For迴圈問題,VB中的For迴圈的問題

把if條件換下就可以了,試試下面的程式 for j 1 to rows 行 for i 1 to columns 列 if j scan int j scan 1.99 then print 1,print 1,str int j scan 0.99 pin1 cstr i print 1,desi...