I have just made a clock that runs off of my computer/time zone etc. I am making a program MDI that has 4 time zone clocks in it. How can i change it so that it is 1 hour difference so that ther are 4 clocks in the program but 1 hour difference?
Printable View
I have just made a clock that runs off of my computer/time zone etc. I am making a program MDI that has 4 time zone clocks in it. How can i change it so that it is 1 hour difference so that ther are 4 clocks in the program but 1 hour difference?
umm... I think i know what you mean but not sure try this:
If you make AmPm = True then it makes the time 12 hour if not it uses 24 hour! Works great I just wrote it for you! Feel special?Code:Dim NewTime, TimeZoneTime, TE
Dim AmPm As Boolean
NewTime = Left$(Time$, 2) + 1
If NewTime < 0 Or NewTime > 24 Then
'Time exceeds or is too low
If NewTime < 0 Then
Do
NewTime = NewTime + 1
Loop Until NewTime >= 0
Else
Do
NewTime = NewTime - 1
Loop Until NewTime <= 24
End If
End If
'For 'American Time' 12 a.m. / 12 p.m.
AmPm = True
If AmPm = True Then
If NewTime > 12 Then
NewTime = NewTime - 12
TE = " PM"
Else
TE = " AM"
End If
End If
TimeZoneTime = NewTime & Right$(Time$, 6) & TE
Text1.Text = TimeZoneTime
Hehe :)
------------------
DiGiTaIErRoR
VB, QBasic, Iptscrae, HTML
Quote: There are no stupid questions, just stupid people.
Intel I would love to get a copy of your clock's source code. I have been trying to make a clock that displayed multiple time zones all at once.
Thanks,
Daniel Christie
[email protected]
You could edit my code to easily do this:
NewTime = Left$(Time$, 2) + 1
That tells it what time to add(in hours) so it only adds one hour but you could change that to + 2 + 3 etc for each time zone also my code has a bug:
Where this is:
change it to:Code:Else
Do
NewTime = NewTime - 1
Loop Until NewTime <= 24
End If
That should work!Code:Else
Do
ln = ln + 1
NewTime = NewTime - 1
Loop Until NewTime <= 24
NewTime = ln
End If
------------------
DiGiTaIErRoR
VB, QBasic, Iptscrae, HTML
Quote: There are no stupid questions, just stupid people.
Here is the code for my clock.
Option Explicit
DefDbl A-Z
Private Sub Form_Load()
Width = 4000
Height = 4000
Left = Screen.Width \ 2 - 4100
Top = (Screen.Height - Height) \ 2
End Sub
Private Sub Form_Resize()
Dim i, Angle
Static Flag As Boolean
If Flag = False Then
Flag = True
For i = 0 To 14
If i > 0 Then Load linClock(i)
linClock(i).Visible = True
linClock(i).BorderWidth = 5
linClock(i).BorderColor = RGB(0, 128, 0)
Next i
End If
For i = 0 To 14
Scale (-1, 1)-(1, -1)
Angle = i * 2 * Atn(1) / 3
linClock(i).X1 = 0.9 * Cos(Angle)
linClock(i).Y1 = 0.9 * Sin(Angle)
linClock(i).X2 = Cos(Angle)
linClock(i).Y2 = Sin(Angle)
Next i
End Sub
Private Sub tmrClock_Timer()
Const HourHand = 0
Const MinuteHand = 13
Const SecondHand = 14
Dim Angle
Static LastSecond
' Position hands only on the second
If Second(Now) = LastSecond Then Exit Sub
LastSecond = Second(Now)
' Position hour hand
Angle = 0.5236 * (15 - (Hour(Now) + Minute(Now) / 60))
linClock(HourHand).X1 = 0
linClock(HourHand).Y1 = 0
linClock(HourHand).X2 = 0.3 * Cos(Angle)
linClock(HourHand).Y2 = 0.3 * Sin(Angle)
' Position minute hand
Angle = 0.1047 * (75 - (Minute(Now) + Second(Now) / 60))
linClock(MinuteHand).X1 = 0
linClock(MinuteHand).Y1 = 0
linClock(MinuteHand).X2 = 0.7 * Cos(Angle)
linClock(MinuteHand).Y2 = 0.7 * Sin(Angle)
' Position second hand
Angle = 0.1047 * (75 - Second(Now))
linClock(SecondHand).X1 = 0
linClock(SecondHand).Y1 = 0
linClock(SecondHand).X2 = 0.8 * Cos(Angle)
linClock(SecondHand).Y2 = 0.8 * Sin(Angle)
End Sub
The form is a simple form with 1 line and a timer control.
I will add some code that you have written here to see if it works. My goal is to have the user enter what time zone they want to see and it shows the appropriate clock based on what they want. I have one clock so far in an MDI form. I just have to have a mnu item so that the user can select the time zone they want and it shows up in the MDI form. The clock stays up until the user needs to have more room where they would close the child form clock. This is primaraly the basis of the program. If anyone would like to help me out e-mail me at [email protected].