史萊姆論壇

史萊姆論壇 (http://forum.slime.com.tw/)
-   程式語言討論區 (http://forum.slime.com.tw/f76.html)
-   -   關於VB6寫一個各地時間的問題? (http://forum.slime.com.tw/thread234345.html)

sob790717b 2008-08-18 09:36 AM

關於VB6寫一個各地時間的問題?
 
請問一下以下程式碼要如何修改才不會有負數的


我是想要修改成 24時時自動進 位到 00時
而且日期也加一天

但是這樣子的時間計算問題就難倒我了
而且又想寫出一個符合各地時間的程式

所以只好請各位大大幫忙嚕:on_22:



程式碼並包含FRM檔各項資訊如下
引用:

VERSION 5.00
Begin VB.Form Form2
BorderStyle = 1 '單線固定
Caption = "各地時間"
ClientHeight = 4725
ClientLeft = 9075
ClientTop = 5715
ClientWidth = 5760
LinkTopic = "Form2"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4725
ScaleWidth = 5760
ShowInTaskbar = 0 'False
Begin VB.Timer Timer1
Interval = 100
Left = 300
Top = 4200
End
Begin VB.CommandButton Command1
Caption = "關閉"
Height = 390
Left = 4125
TabIndex = 8
Top = 4275
Width = 1440
End
Begin VB.Frame Frame1
Caption = "各地時間"
Height = 3915
Left = 300
TabIndex = 0
Top = 225
Width = 5265
Begin VB.TextBox Text28
Height = 315
Left = 2100
TabIndex = 58
Text = "Text1"
Top = 300
Width = 465
End
Begin VB.TextBox Text27
Height = 315
Left = 2100
TabIndex = 57
Text = "Text1"
Top = 750
Width = 465
End
Begin VB.TextBox Text26
Height = 315
Left = 2100
TabIndex = 56
Text = "Text1"
Top = 1200
Width = 465
End
Begin VB.TextBox Text25
Height = 315
Left = 2100
TabIndex = 55
Text = "Text1"
Top = 1650
Width = 465
End
Begin VB.TextBox Text24
Height = 315
Left = 2100
TabIndex = 54
Text = "Text1"
Top = 2100
Width = 465
End
Begin VB.TextBox Text23
Height = 315
Left = 2100
TabIndex = 53
Text = "Text1"
Top = 2550
Width = 465
End
Begin VB.TextBox Text22
Height = 315
Left = 2100
TabIndex = 52
Text = "Text1"
Top = 3000
Width = 465
End
Begin VB.TextBox Text21
Height = 315
Left = 4350
TabIndex = 36
Text = "Text1"
Top = 300
Width = 465
End
Begin VB.TextBox Text20
Height = 315
Left = 4350
TabIndex = 35
Text = "Text1"
Top = 750
Width = 465
End
Begin VB.TextBox Text19
Height = 315
Left = 4350
TabIndex = 34
Text = "Text1"
Top = 1200
Width = 465
End
Begin VB.TextBox Text18
Height = 315
Left = 4350
TabIndex = 33
Text = "Text1"
Top = 1650
Width = 465
End
Begin VB.TextBox Text17
Height = 315
Left = 4350
TabIndex = 32
Text = "Text1"
Top = 2100
Width = 465
End
Begin VB.TextBox Text16
Height = 315
Left = 4350
TabIndex = 31
Text = "Text1"
Top = 2550
Width = 465
End
Begin VB.TextBox Text15
Height = 315
Left = 4350
TabIndex = 30
Text = "Text1"
Top = 3000
Width = 465
End
Begin VB.TextBox Text14
Height = 315
Left = 3600
TabIndex = 22
Text = "Text1"
Top = 300
Width = 465
End
Begin VB.TextBox Text13
Height = 315
Left = 3600
TabIndex = 21
Text = "Text1"
Top = 750
Width = 465
End
Begin VB.TextBox Text12
Height = 315
Left = 3600
TabIndex = 20
Text = "Text1"
Top = 1200
Width = 465
End
Begin VB.TextBox Text11
Height = 315
Left = 3600
TabIndex = 19
Text = "Text1"
Top = 1650
Width = 465
End
Begin VB.TextBox Text10
Height = 315
Left = 3600
TabIndex = 18
Text = "Text1"
Top = 2100
Width = 465
End
Begin VB.TextBox Text9
Height = 315
Left = 3600
TabIndex = 17
Text = "Text1"
Top = 2550
Width = 465
End
Begin VB.TextBox Text8
Height = 315
Left = 3600
TabIndex = 16
Text = "Text1"
Top = 3000
Width = 465
End
Begin VB.TextBox Text7
Height = 315
Left = 2850
TabIndex = 15
Text = "Text1"
Top = 3000
Width = 465
End
Begin VB.TextBox Text6
Height = 315
Left = 2850
TabIndex = 14
Text = "Text1"
Top = 2550
Width = 465
End
Begin VB.TextBox Text5
Height = 315
Left = 2850
TabIndex = 13
Text = "Text1"
Top = 2100
Width = 465
End
Begin VB.TextBox Text4
Height = 315
Left = 2850
TabIndex = 12
Text = "Text1"
Top = 1650
Width = 465
End
Begin VB.TextBox Text3
Height = 315
Left = 2850
TabIndex = 11
Text = "Text1"
Top = 1200
Width = 465
End
Begin VB.TextBox Text2
Height = 315
Left = 2850
TabIndex = 10
Text = "Text1"
Top = 750
Width = 465
End
Begin VB.TextBox Text1
Height = 315
Left = 2850
TabIndex = 9
Text = "Text1"
Top = 300
Width = 465
End
Begin VB.Label Label36
Caption = "日"
Height = 165
Left = 2625
TabIndex = 65
Top = 3150
Width = 165
End
Begin VB.Label Label35
Caption = "日"
Height = 165
Left = 2625
TabIndex = 64
Top = 2700
Width = 165
End
Begin VB.Label Label34
Caption = "日"
Height = 165
Left = 2625
TabIndex = 63
Top = 2250
Width = 165
End
Begin VB.Label Label33
Caption = "日"
Height = 165
Left = 2625
TabIndex = 62
Top = 1800
Width = 165
End
Begin VB.Label Label32
Caption = "日"
Height = 165
Left = 2625
TabIndex = 61
Top = 1350
Width = 165
End
Begin VB.Label Label31
Caption = "日"
Height = 165
Left = 2625
TabIndex = 60
Top = 900
Width = 165
End
Begin VB.Label Label30
Caption = "日"
Height = 165
Left = 2625
TabIndex = 59
Top = 450
Width = 165
End
Begin VB.Label Label29
Caption = "註 : 程式設計時以台灣時間 (GMT+08:00) 為基礎"
Height = 165
Left = 75
TabIndex = 51
Top = 3675
Width = 4890
End
Begin VB.Label Label28
Caption = "秒"
Height = 165
Left = 4875
TabIndex = 50
Top = 450
Width = 165
End
Begin VB.Label Label27
Caption = "秒"
Height = 240
Left = 4875
TabIndex = 49
Top = 900
Width = 165
End
Begin VB.Label Label26
Caption = "秒"
Height = 240
Left = 4875
TabIndex = 48
Top = 1350
Width = 165
End
Begin VB.Label Label25
Caption = "秒"
Height = 240
Left = 4875
TabIndex = 47
Top = 1800
Width = 165
End
Begin VB.Label Label24
Caption = "秒"
Height = 165
Left = 4875
TabIndex = 46
Top = 2250
Width = 165
End
Begin VB.Label Label23
Caption = "秒"
Height = 240
Left = 4875
TabIndex = 45
Top = 2625
Width = 165
End
Begin VB.Label Label22
Caption = "秒"
Height = 240
Left = 4875
TabIndex = 44
Top = 3150
Width = 165
End
Begin VB.Label Label21
Caption = "分"
Height = 165
Left = 4125
TabIndex = 43
Top = 450
Width = 165
End
Begin VB.Label Label20
Caption = "分"
Height = 165
Left = 4125
TabIndex = 42
Top = 900
Width = 165
End
Begin VB.Label Label19
Caption = "分"
Height = 165
Left = 4125
TabIndex = 41
Top = 1350
Width = 165
End
Begin VB.Label Label18
Caption = "分"
Height = 165
Left = 4125
TabIndex = 40
Top = 1800
Width = 165
End
Begin VB.Label Label17
Caption = "分"
Height = 165
Left = 4125
TabIndex = 39
Top = 2250
Width = 165
End
Begin VB.Label Label16
Caption = "分"
Height = 165
Left = 4125
TabIndex = 38
Top = 2700
Width = 165
End
Begin VB.Label Label15
Caption = "分"
Height = 165
Left = 4125
TabIndex = 37
Top = 3150
Width = 165
End
Begin VB.Label Label14
Caption = "時"
Height = 165
Left = 3375
TabIndex = 29
Top = 450
Width = 165
End
Begin VB.Label Label13
Caption = "時"
Height = 165
Left = 3375
TabIndex = 28
Top = 900
Width = 165
End
Begin VB.Label Label12
Caption = "時"
Height = 165
Left = 3375
TabIndex = 27
Top = 1350
Width = 165
End
Begin VB.Label Label11
Caption = "時"
Height = 165
Left = 3375
TabIndex = 26
Top = 1800
Width = 165
End
Begin VB.Label Label10
Caption = "時"
Height = 165
Left = 3375
TabIndex = 25
Top = 2250
Width = 165
End
Begin VB.Label Label9
Caption = "時"
Height = 165
Left = 3375
TabIndex = 24
Top = 2700
Width = 165
End
Begin VB.Label Label8
Caption = "時"
Height = 165
Left = 3375
TabIndex = 23
Top = 3150
Width = 165
End
Begin VB.Label Label7
Caption = "美國時間"
Height = 240
Left = 225
TabIndex = 7
Top = 3150
Width = 1215
End
Begin VB.Label Label6
Caption = "泰國時間"
Height = 240
Left = 225
TabIndex = 6
Top = 2700
Width = 840
End
Begin VB.Label Label5
Caption = "韓國時間"
Height = 165
Left = 225
TabIndex = 5
Top = 2250
Width = 840
End
Begin VB.Label Label4
Caption = "香港時間"
Height = 240
Left = 225
TabIndex = 4
Top = 1800
Width = 840
End
Begin VB.Label Label3
Caption = "中國時間"
Height = 240
Left = 225
TabIndex = 3
Top = 1350
Width = 915
End
Begin VB.Label Label2
Caption = "台灣時間"
Height = 240
Left = 225
TabIndex = 2
Top = 900
Width = 840
End
Begin VB.Label Label1
Caption = "GMT"
Height = 165
Left = 225
TabIndex = 1
Top = 450
Width = 915
End
End
End
Attribute VB_Name = "Form2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Form2.Hide
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.Caption = "GMT"
Label2.Caption = "台灣時間"
Label3.Caption = "中國時間"
Label4.Caption = "香港時間"
Label5.Caption = "韓國時間"
Label6.Caption = "泰國時間"
Label7.Caption = "美國時間"

End Sub

Private Sub Frame1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label1.Caption = "GMT"
Label2.Caption = "台灣時間"
Label3.Caption = "中國時間"
Label4.Caption = "香港時間"
Label5.Caption = "韓國時間"
Label6.Caption = "泰國時間"
Label7.Caption = "美國時間"

End Sub

Private Sub Label3_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label3.Caption = "北京"

End Sub

Private Sub Label5_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label5.Caption = "南韓"

End Sub

Private Sub Label7_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Label7.Caption = "美東華盛頓"

End Sub

Private Sub Timer1_Timer()
gmthr = Hour(Time) - 8
gmtmin = Minute(Time)
gmtsec = Second(Time)
gmtday = Day(Date)

Text1.Text = "" & gmthr
Text2.Text = "" & gmthr + 8
Text3.Text = "" & gmthr + 8
Text4.Text = "" & gmthr + 8
Text5.Text = "" & gmthr + 9
Text6.Text = "" & gmthr + 7
Text7.Text = "" & gmthr - 5



Text8.Text = "" & gmtmin
Text9.Text = "" & gmtmin
Text10.Text = "" & gmtmin
Text11.Text = "" & gmtmin
Text12.Text = "" & gmtmin
Text13.Text = "" & gmtmin
Text14.Text = "" & gmtmin


Text15.Text = "" & gmtsec
Text16.Text = "" & gmtsec
Text17.Text = "" & gmtsec
Text18.Text = "" & gmtsec
Text19.Text = "" & gmtsec
Text20.Text = "" & gmtsec
Text21.Text = "" & gmtsec


Text22.Text = "" & gmtday
Text23.Text = "" & gmtday
Text24.Text = "" & gmtday
Text25.Text = "" & gmtday
Text26.Text = "" & gmtday
Text27.Text = "" & gmtday
Text28.Text = "" & gmtday

If Text1.Text <= -1 Then Text28.Text = "" & gmtday - 1
If Text2.Text <= -1 Then Text27.Text = "" & gmtday - 1
If Text3.Text <= -1 Then Text26.Text = "" & gmtday - 1
If Text4.Text <= -1 Then Text25.Text = "" & gmtday - 1
If Text5.Text <= -1 Then Text24.Text = "" & gmtday - 1
If Text6.Text <= -1 Then Text23.Text = "" & gmtday - 1
If Text7.Text <= -1 Then Text22.Text = "" & gmtday - 1


If Text1.Text >= 24 Then Text28.Text = "" & gmtday + 1 ' And Text1.Text - 24
If Text2.Text >= 24 Then Text27.Text = "" & gmtday + 1
If Text3.Text >= 24 Then Text26.Text = "" & gmtday + 1
If Text4.Text >= 24 Then Text25.Text = "" & gmtday + 1
If Text5.Text >= 24 Then Text24.Text = "" & gmtday + 1 ' And Text5.Text - 24
If Text6.Text >= 24 Then Text23.Text = "" & gmtday + 1 ' And Text6.Text - 24
If Text7.Text >= 24 Then Text22.Text = "" & gmtday + 1 ' And Text7.Text - 24


If Text1.Text = 24 Then Text1.Text = "" & gmthr - 24
If Text2.Text = 24 Then Text2.Text = "" & gmthr - 24
If Text3.Text = 24 Then Text3.Text = "" & gmthr - 24
If Text4.Text = 24 Then Text4.Text = "" & gmthr - 24
If Text5.Text = 24 Then Text5.Text = "" & gmthr - 24
If Text6.Text = 24 Then Text6.Text = "" & gmthr - 24
If Text7.Text = 24 Then Text7.Text = "" & gmthr - 24



End Sub


飛行船大大 2008-08-18 02:28 PM

縮排 請用 [code] 會比較容易閱讀 ~
在http://www.planet-source-code.com/ 有一些符合你要的範例
你搜文尋票數高的 有關日期,時鐘類 即可~

superxboy 2008-08-18 04:14 PM

語法:

    If Text1.Text = 24 Then Text1.Text = Format(gmthr - 24, "00")
    If Text2.Text = 24 Then Text2.Text = Format(gmthr - 24, "00")
    If Text3.Text = 24 Then Text3.Text = Format(gmthr - 24, "00")
    If Text4.Text = 24 Then Text4.Text = Format(gmthr - 24, "00")
    If Text5.Text = 24 Then Text5.Text = Format(gmthr - 24, "00")
    If Text6.Text = 24 Then Text6.Text = Format(gmthr - 24, "00")
    If Text7.Text = 24 Then Text7.Text = Format(gmthr - 24, "00")


sob790717b 2008-08-19 03:03 PM

引用:

作者: superxboy (文章 2009750)
語法:

    If Text1.Text = 24 Then Text1.Text = Format(gmthr - 24, "00")
    If Text2.Text = 24 Then Text2.Text = Format(gmthr - 24, "00")
    If Text3.Text = 24 Then Text3.Text = Format(gmthr - 24, "00")
    If Text4.Text = 24 Then Text4.Text = Format(gmthr - 24, "00")
    If Text5.Text = 24 Then Text5.Text = Format(gmthr - 24, "00")
    If Text6.Text = 24 Then Text6.Text = Format(gmthr - 24, "00")
    If Text7.Text = 24 Then Text7.Text = Format(gmthr - 24, "00")




正在把碼抓回去測試中

感謝大大提供

sob790717b 2008-08-20 06:50 PM

引用:

作者: 飛行船大大 (文章 2009717)
縮排 請用 [code] 會比較容易閱讀 ~
在http://www.planet-source-code.com/ 有一些符合你要的範例
你搜文尋票數高的 有關日期,時鐘類 即可~



那麼日期呢

我看過有一些世界各地時間網站他是如何知道什後該加一天
什麼時候該減一天

是否可以應用到VB6 之上呢?:on_47:

mraaa711128 2008-08-23 09:20 PM

引用:

作者: sob790717b (文章 2011544)
那麼日期呢

我看過有一些世界各地時間網站他是如何知道什後該加一天
什麼時候該減一天

是否可以應用到VB6 之上呢?:on_47:


我記得VB6有很多時間函式可以直接加一小時加一天或加一個月甚至加年
應該是叫DateAdd.....還是DateDiff.....根本不用自己去算什麼潤不閏年還是是大月小月
他全部都會自己算!!只要告訴那個函式你是要加"秒 or 分 or 時 or 日 or 月 or 年"
還有要加多少(整數<Integer>),再給一個基準日期!!

下面是範例
dim WK_RESULT_DATE as date
dim WK_NOW_DATE as date

wk_now_date=now
wk_result_date=dateadd("m" , 1 , wk_now_date)<===這樣就會把結果值放入"WK_RESULT_DATE"這個變數....<這是加一個月做例子!!>
自己看一下說明檔
關於"m"的用法....^^

對不起....新手......文章有點亂......沒排版......


所有時間均為台北時間。現在的時間是 05:55 PM

Powered by vBulletin® 版本 3.6.8
版權所有 ©2000 - 2025, Jelsoft Enterprises Ltd.

『服務條款』

* 有問題不知道該怎麼解決嗎?請聯絡本站的系統管理員 *


SEO by vBSEO 3.6.1