In VB6 you can put a timer and set the interval to 1 second and show the time in a label with something like
label1.caption = time
Check the VB help file to see how to change the format.
In VBA you don't have timers, so you'll have to work with DoEvents and an endless DO, something like
Do
label1.Caption = Time
DoEvents
Loop
And for the analog clock just create some lines and change the coordinates of their ends (use some trigonometric functions to increase 6° the angle each time)
... And for the analog clock just create some lines and change the coordinates of their ends (use some trigonometric functions to increase 6° the angle each time)
Hi
Can you give me a short example for analog clock
I'll very thankful to you.
May God bless you.
Last edited by Killer42; Aug 28 '07, 08:26 AM.
Reason: Shortened excessive quote block, removed "Plzzzzzz"
Thanks but I want the digital clock made by dots means some dots will make numbers for the clock not displaying it in label.
You can make some picture boxes and add each the image or the dots you want to show.
Use the functions Hour, Minute and Second to get each number.
Suppose you have the numbers in picture boxes named as the number and make some cases:
You can put something like this in your timer
[CODE=vb]Select Case Hour(Time)
Case 1
picturebox1.Pic ture = one.Picture
Case 2
picturebox1.Pic ture = two.Picture
' (...and so on ...)
End Select[/CODE]
Originally posted by Ali Rizwan
Hi
Can you give me a short example for analog clock
I'll very thankful to you.
May God bless you
Sure, just make 3 lines in VB (I don't know how to make them in VBA)
Let's say the center of the clock is at 200, 200.
Remember the formula for a circle is X^2 + Y^2 = r^2, and lets say that r (the length of the line) will be 50, and will be the minute hand
x1 will always be 200
y1 will always be 200 too
The angle will be 90 - 6 * Minute(Time)
And if this is negative let's just add 360 to it. Something like:
Dim angle As Single
angle = 90 - (6 * Minute(Time))
If angle < 0 Then angle = angle + 360
Now see then sin(angle) = Y/r and cos(angle) = X/r.
Remember that you have your center at 200,200 and you're done:
line1.X2 = 200 - r * Cos(angle)
line1.Y2 = 200 - r * Sin(angle)
Something like that should work, I didn't revise it since I have a lot of work here (sorry about that) but it's the main idea.
Oh i see it but there is large coding behind it but thanks a lot it will help me lot.
I would hardly call it "large" coding. And some of it can be removed. For example, I see there's code in there to stop waiting and update immediately if the user double-clicks on it or presses a key.
Comment