473,466 Members | 1,451 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Clock making

Ali Rizwan
925 Contributor
Hi
How to make clocks
Analog and digital
Can somebody help me
Aug 27 '07 #1
10 3399
kadghar
1,295 Recognized Expert Top Contributor
It depends on which version of VB you are using.

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)

Good Luck
Aug 27 '07 #2
Ali Rizwan
925 Contributor
it depends on wich version of VB ...
Thanks but I want the digital clock made by dots means some dots will make numbers for the clock not displaying it in label.
Aug 27 '07 #3
Ali Rizwan
925 Contributor
... 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.
Aug 27 '07 #4
kadghar
1,295 Recognized Expert Top Contributor
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

Expand|Select|Wrap|Line Numbers
  1. Select Case Hour(Time)
  2.     Case 1
  3.         picturebox1.Picture = one.Picture
  4.     Case 2
  5.         picturebox1.Picture = two.Picture
  6. ' (...and so on ...)
  7. End Select

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.

Good Luck
Aug 27 '07 #5
Ali Rizwan
925 Contributor
You can make some picture boxes ... Good Luck
Thanks a lot for all this
Aug 28 '07 #6
Killer42
8,435 Recognized Expert Expert
Hi
How to make clocks
Analog and digital
Can somebody help me
Here's one I prepared earlier. :)

About seven years earlier, to be precise. In VB3.

Just add the form file to a new project, and run it.
Attached Files
File Type: zip BigClock.zip (1.7 KB, 217 views)
Aug 28 '07 #7
Ali Rizwan
925 Contributor
Here's one I prepared earlier. :)

About seven years earlier, to be precise. In VB3.

Just add the form file to a new project, and run it.
Oh i see it but there is large coding behind it but thanks a lot it will help me lot.
Aug 28 '07 #8
sephirote
3 New Member
right click in the componentsand find digital clock and apply it in your form that's the way it is....so simple!try it....
Aug 28 '07 #9
Killer42
8,435 Recognized Expert Expert
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.
Aug 29 '07 #10
Killer42
8,435 Recognized Expert Expert
right click in the componentsand find digital clock and apply it in your form that's the way it is....so simple!try it....
This must be a VB.Net thing, right?
Aug 29 '07 #11

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: James Harriman | last post by:
Hi, I need to be able to measure a time interval in milliseconds on a windows machine. I have tried using time.clock() but it appears to measure time in seconds...Is there a way to measure time...
5
by: Robert | last post by:
Hello all, I use clock() to measure the time cost in my program. But the t_clock always be the multiply of 10, for example 10, 20, 30, 40,... And I want to get the precision of 1, such as 11,...
33
by: Pushkar Pradhan | last post by:
I'm using clock() to time parts of my code e.g. clk1 = clock(); /* code */ clk2 = clock(); /* calculate time in secs */ ...... clk1 = clock(); /* code */ clk2 = clock();
12
by: aegis | last post by:
What is wall clock time? the standard doesn't define it but I see its use in past posts on clc. -- aegis
54
by: CoreyWhite | last post by:
The following experiment is a demonstration of TIME TRAVEL. When writing this program, and testing it out I found that sometimes the program would engage itself in time travel but other times it...
30
by: Matt | last post by:
Does clock_t clock() measure real time or process time? Unless I have missed something, Stroustrup's treatment in TC++PL (section D.4.4.1) is none too clear on that question. Is clock()...
18
by: Giovanni Bajo | last post by:
Hello, I experimented something very strange, a few days ago. I was debugging an application at a customer's site, and the problem turned out to be that time.clock() was going "backwards", that...
12
by: cenktarhancenk | last post by:
is there a way to display a ticking clock in a web page using javascript? but not in a textbox, rather as text that i can change the style, font etc. cenk tarhan
5
by: none | last post by:
Hello, can you help? if I include: #include <time.h> and run the code: clock_t t = clock(); cout << "t is " << t << endl; I get (seemingly randomly) "t is 0" or "t is 10000"
5
by: Charles May | last post by:
Anyone have a simple concept for the best way to store timeclock information in a database. I currently have my table set up like this with a typical daily entry. tcID empID Type ...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.