SlideShare a Scribd company logo
1 of 12
Download to read offline
8/28/2014 www.martin2k.co.uk/vb6/tips/vb_41.php 
Search 
Free clock-in/out service 
razortime.com 
Perfect for sm all businesses Live tim e sheets, great overview 
Home | Forums | VB6 | Games | Software | Directory | HTML | Wiki | Blog | 
Contact 
Clock 
Program 
The Clock program displays the time using big numbers, which resemble 
those from a digital clock in real life. You can download the source code 
from here: 
vb_41_clock.zip (9.3 KB) 
The compiled program can be downloaded from the Downloads page. 
Here is how to make it: 
This program uses the following ActiveX controls: 
Microsoft Windows Common Controls 6.0 (SP6) 
(MSCOMCTL.OCX) 
First, design a Form, which looks similar to this: 
The Clock Form 
The Form includes six Image controls (Hour1, Hour2, Min1, Min2, Sec1 
and Sec2), four Labels (the colons, one at the bottom for the date 
http://www.martin2k.co.uk/vb6/tips/vb_41.php 1/12
8/28/2014 www.martin2k.co.uk/vb6/tips/vb_41.php 
(lblDate) and one on the right of the Form to display 'AM' or 'PM' 
(lblAMPM)), a Timer (timTime - not displayed above) and an ImageList 
(ImgNum). The ImageList contains numbers from 1 - 9 and then 0 as 
images. You can use the ones, included in the source code ZIP file or 
you can use your own e.g.: 
ImageList Property Pages 
To get the Form to be the topmost on the screen, the following API 
function and constants need to be declared: 
Private Declare Sub SetWindowPos Lib "User32" (ByVal hWnd As Long, 
ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, 
ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) 
Const HWND_TOPMOST = -1 
Const SWP_NOACTIVATE = &H10 
Const SWP_SHOWWINDOW = &H40 
The following code needs to be put into the Form Load event. The 
centre line sets the window as the topmost window: 
Private Sub Form_Load() 
lblDate.Caption = Time & " - " & Format(Date, "Long Date") 
'Set window as topmost 
SetWindowPos hWnd, HWND_TOPMOST, Left / 15, Top / 15, Width / 15, 
Height / 15, SWP_NOACTIVATE Or SWP_SHOWWINDOW 
ClockT.Interval = (1 - (Int(Timer) Mod 1)) * 1000 
End Sub 
Here is the code for the Timer: 
DIGITAL 
CLOCK IN 
BULK 
alibaba.com 
Choose from 
1M+ Verified 
Suppliers. 
Contact 
Directly & Get 
Live Quotes! 
http://www.martin2k.co.uk/vb6/tips/vb_41.php 2/12
8/28/2014 www.martin2k.co.uk/vb6/tips/vb_41.php 
Private Sub timTime_Timer() 
On Error GoTo Eror 
Dim t As String, H1 As Integer, H2 As Integer, M1 As Integer, M2 
As Integer, S1 As Integer, S2 As Integer 
t = Time 
If Len(Time) = 10 Then t = 0 & t 
t = Replace(t, ":", "") 
t = Replace(t, " ", "") 
lblAMPM.Caption = Right(t, 2) 
t = Replace(t, "PM", "") 
t = Replace(t, "AM", "") 
H1 = Mid(t, 1, 1) 
H2 = Mid(t, 2, 1) 
M1 = Mid(t, 3, 1) 
M2 = Mid(t, 4, 1) 
S1 = Mid(t, 5, 1) 
S2 = Mid(t, 6, 1) 
ClockSet Hour1, H1 
ClockSet Hour2, H2 
ClockSet Min1, M1 
ClockSet Min2, M2 
ClockSet Sec1, S1 
ClockSet Sec2, S2 
lblDate.Caption = Format(Date, "Long Date") 
Exit Sub 
Eror: 
If Err = 13 Then MsgBox "This program will only work if you set 
'Start, Settings, Control Panel, Regional Settings, Time, Time 
separator:' to ':' (colon).", 16, "Error" 
Unload frmClock 
End Sub 
This code works by firstly creating a string (t) that the program can 
work with easily e.g. "9:09:28 PM" would be converted into "090928". 
Next, the H1, H2, M1, M2, S1 and S2 variables are given values from 
this string by extracting numbers using the Mid function. Afterwards, the 
ClockSet function is given each variable and puts the number for it on 
the Form. 
The code for the ClockSet function is as follows: 
Sub ClockSet(Img As Image, Number As Integer) 
If Number = 0 Then Number = 10 
Img.Picture = ImgNum.ListImages.Item(Number).Picture 
End Sub 
As the image for '0' is in the number 10 position in the ImageList, the 
program has to be told to get the image for '0' from this position hence 
the first line. 
http://www.martin2k.co.uk/vb6/tips/vb_41.php 3/12
8/28/2014 www.martin2k.co.uk/vb6/tips/vb_41.php 
The end result should look like this: 
The Clock Program 
Additional Information by Martin Allen: 
To display the time in a different time zone, just change the following 
code in the timTime_Timer event: 
t = Time 
to: 
t = Time - 12 / 24 
The above example will subtract half a day, or 12 hours. The first 
number can be set to the number of hours you want to add or subtract. 
E.g. to subtract one hour, change the first number to 1. To add an hour, 
use '+' instead of '-' and change the first number to 1. 
http://www.martin2k.co.uk/vb6/tips/vb_41.php 4/12
8/28/2014 www.martin2k.co.uk/vb6/tips/vb_41.php 
4 Comments martin2k 1 Login 
Sort by Best Share 
Join the discussion… 
Favorite 
Riahgrace • 3 years ago 
.. lisud maN.. kani unTa aKuang e himo sa mU tlE sa compUter.. pro timer 
nLang aKua.. tHanx sa infO!! :) 
1 
• Reply • 
Share › 
Villasmarlon • 3 years ago 
the best 
• Reply • 
Share › 
tausif • 3 years ago 
nice 
• Reply • 
Share › 
Kyle46 • 3 years ago 
Best download ever!!!!!! 
• Reply • 
Share › 
Subscribe Add Disqus to your site 
blog comments powered by Disqus 
Archived Comments 
From: Gajendra 
Date: Thursday, December 2, 2010 at 16:45:48 
Comments: hi..guys..it's site very useful for us......nict to feel get 
it....thankyou 
From: NMSundaram 
Date: Tuesday, November 30, 2010 at 16:43:13 
Comments: Hi..! Very congratulations for your nice clock program and 
one request for u is that can u help me for going in deep 
with vb 6.0 & vb.net as i have to be a very good 
programmer in my life.. Thanks 
From: Kadir Khan 
http://www.martin2k.co.uk/vb6/tips/vb_41.php 5/12
8/28/2014 www.martin2k.co.uk/vb6/tips/vb_41.php 
Date: Wednesday, November 10, 2010 at 16:09:32 
Comments: hey dude this site is very helpfull of my major project and 
u believe my practical marks is 100 to 85..........thans 
From: Musa Adamu 
Date: Sunday, January 10, 2010 at 12:55:54 
Comments: it was to day 9thjanuary, that i sees this program and its 
very interested keep it up for more useful codes to all 
programmers. i wish you the best. 
From: Pradeep 
Date: Sunday, November 8, 2009 at 11:45:30 
Comments: Fantastic. Thanks so much for sharing the code with 
others. 
From: dmash 
Date: Tuesday, October 6, 2009 at 14:27:00 
Comments: this is cool, keep it up. 
From: abdur 
Date: Monday, August 24, 2009 at 09:12:12 
Comments: It is a very nice idea and programming technique in simple 
ways it is explainded thanks a lot! 
From: niranjan 
Date: Friday, May 1, 2009 at 05:40:06 
Comments: Thanks for sharing ur idea and programming knowledge 
with every1...Carry on .... 
From: jomar 
Date: Saturday, September 27, 2008 at 15:57:28 
Comments: very... good... po nakuha ko po 2 thanks.. to all/ 
From: Neo_BeKaBe 
Date: Monday, September 22, 2008 at 05:53:41 
Comments: Great guys...! 
Thanks so much...! 
From: king george akom 
Date: Wednesday, September 17, 2008 at 20:39:14 
Comments: how you help people develop their programing skills is the 
best.continue with the good work 
From: Waqar Ahmed Bhutto 
http://www.martin2k.co.uk/vb6/tips/vb_41.php 6/12
8/28/2014 www.martin2k.co.uk/vb6/tips/vb_41.php 
Date: Wednesday, August 13, 2008 at 09:46:13 
Comments: Hi iam sdt of Quest Nawabshah in computer system 
Engineering,,,, Well your project is amezing.. also i use 
yours project in my assignments.. thax 
From: mahantesh 
Date: Wednesday, April 23, 2008 at 12:39:51 
Comments: hi congratulations nice programs 
From: Shankar Dinkar Patil 
Date: Sunday, February 10, 2008 at 07:41:14 
Comments: that good program in a vb lang. in supo. 
From: krishna 
Date: Thursday, January 31, 2008 at 06:49:44 
Comments: hi.... its me krishna 
its been very useful for us to develop our vb knowledge... 
neway keep ,ur works move 
From: mjohn 
Date: Wednesday, January 30, 2008 at 05:28:53 
Comments: hi, I'm a newbie in vb programming i like your programs.. 
And right now i'm studying the way you code i need to 
learn vb6.0 for my projects thanks for sharing your vb 
projects.. 
From: kaustubh 
Date: Tuesday, January 29, 2008 at 07:45:07 
Comments: its interesting the codes 
From: Brentan 
Date: Friday, October 19, 2007 at 10:09:22 
Comments: 
for some reason when i tried to create my own clock 
using your code the line: 
Img.Picture = ImgNum.ListImages.Item(Number).Picture 
always comes up as method or data member not found. 
need help 
Reply: 
Have you named your ImageList control ImgNum? Is the 
argument 'Img' present in your 'ClockSet' procedure? 
http://www.martin2k.co.uk/vb6/tips/vb_41.php 7/12
8/28/2014 www.martin2k.co.uk/vb6/tips/vb_41.php 
Have a look at the source code to compare it to yours. 
From: ahmad dukku 
Date: Tuesday, September 11, 2007 at 13:28:18 
Comments: its interesting the codes 
From: Nurudeen 
Date: Saturday, August 25, 2007 at 01:00:15 
Comments: I love this stuff the code are important to me. What 
makes a programmer if he/she don't know how to write 
programmes or develop softward 
From: dhondhoncraze 
Date: Wednesday, August 1, 2007 at 04:53:23 
Comments: Hey your work is nice, but it is very simple, i can make 
that one in just few minute; by the way i'm a programmer 
also; keep up the good work; your great!!!!!!!!!!!!!!! 
From: nadeem arain 
Date: Monday, July 30, 2007 at 15:03:36 
Comments: this is a nice clock 
+923003238138 
From: AMEER 
Date: Friday, June 8, 2007 at 13:03:10 
Comments: You coding intuitiveness is so much helpful for all level of 
programmers. Thanks a lot. May you think of more such 
codes. 
From: sanela 
Date: Friday, June 1, 2007 at 12:21:22 
Comments: hello i write from bosnia and herzegovina i have school 
asigment i have to make some simple program in Visual 
Basic, i dont know have,i dont have any litherature,and i 
cant download any of this programs,i really like clock 
program it looks great, byyy sanela 
From: sachin nimkar 
Date: Wednesday, May 2, 2007 at 08:10:46 
Comments: your clock program is cooool iwant another also 
From: phani 
Date: Friday, April 6, 2007 at 15:26:31 
http://www.martin2k.co.uk/vb6/tips/vb_41.php 8/12
8/28/2014 www.martin2k.co.uk/vb6/tips/vb_41.php 
Comments: clock program is very nice. 
From: ardie 
Date: Tuesday, April 3, 2007 at 03:32:26 
Comments: hello... i like ur program its very nice.... ur the best 
programer ive ever scne... good luck /// 
From: Umair 
Date: Friday, March 23, 2007 at 11:50:39 
Comments: i'm from england, gr8 work man, it can be even greater if 
u cud add alarm to it, in order to alarm the user about n e 
special event. 
Reply: 
All you would need to do is to test whether the current time 
matches the time you want an event to occur e.g. you could try 
the following code in the timTime_Timer() event. Make sure 
you declare a Boolean variable called Alarm. 
... 
lblAMPM.Caption = Right(t, 2) 
If Alarm = False Then 
If t = "080000AM" Then 
Alarm = True 
Shell "C:Program FilesWindows Media 
Playerwmplayer.exe c:music.mp3", vbNormalFocus 
End If 
End If 
If t = "080001AM" Then Alarm = False 
t = Replace(t, "PM", "") 
... 
From: Anil kumar 
Date: Tuesday, January 9, 2007 at 12:21:11 
Comments: Hi, 
this is anil...I am from Bangalore[India].I am doing my 
final year computer science. 
About ur clock Program,it is wonderfull. I am in need 
help.can u help me. How to get quick knowlege in vb? 
Regards 
[Anil Kumar) 
From: syefriadi 
Date: Friday, January 5, 2007 at 03:22:08 
Comments: I am very glad to follow your website and your source 
http://www.martin2k.co.uk/vb6/tips/vb_41.php 9/12
8/28/2014 www.martin2k.co.uk/vb6/tips/vb_41.php 
code. 
From: joginder kumar 
Date: Monday, December 11, 2006 at 08:56:04 
Comments: Hi I am indian !!. very congatulations for ur nice clock 
programm and one request for u is that can u help me for 
going in deep with vb 6.0 & vb.net as i have to be a very 
good programmer in my life.. Thanks 
From: Rehan Shah 
Date: Thursday, November 30, 2006 at 17:22:32 
Comments: I m from Karachi.It is really nice work .I want to be a VB 
Programmer in future. I used these programs and i found 
them excellent. If u have any new project so email i need 
to learn. 
From: Irudaya Raja 
Date: Monday, November 13, 2006 at 14:59:48 
Comments: Hai! I am an Indian. I am very glad to follow your website 
and your source code. This Clock theme is very useful for 
me. 
From: Clydlanne 
Date: Friday, September 29, 2006 at 07:40:51 
Comments: Hi! I am a 3rd year BSCS student. Well, you have a nice 
program. Keep the good work. Your clock program is 
really perfect! Bye! Have a nice day! 
From: arun <bindasaks2005@!gmail.com> 
Date: Thursday, September 14, 2006 at 13:36:37 
Comments: wonderful 
From: Santosh Yadav 
Date: Tuesday, August 29, 2006 at 07:49:56 
Comments: Hi, 
I m from India.It is really nice work .I want to be a VB 
Programmer too. Hope you can help me (i u wish). 
Bye 
From: omkar kanitkar 
Date: Thursday, February 2, 2006 at 06:54:45 
Comments: i am indian, now in russia (for education). i have simpler 
codes for the same clock program. but still i need some 
help in creating other projects. so pls e mail me your e 
mail address(if you wish to help). thanks. 
http://www.martin2k.co.uk/vb6/tips/vb_41.php 10/12
8/28/2014 www.martin2k.co.uk/vb6/tips/vb_41.php 
From: rafay ikram 
Date: Saturday, January 28, 2006 at 18:47:01 
Comments: i used these programs and i found them excellent 
thanx for these programs 
From: Pepe Rojas 
Date: Tuesday, November 29, 2005 at 20:05:46 
Comments: Hi, ¿do you speak spanish?, I'm from México. My english is 
not good, but I will try to use it. 
My question is: Why you need APIs and, image control and 
OCX, if you can do it with a text box with a font like LCD o 
some similar. and calling the function TIME, is more easy 
and the file is more light. Later I will send you my version 
of clock to you put it on your web. If you can, send me 
the answer to my mail. 
Pepe. 
Reply: The API function is used to keep the window above others - it 
does not have anything to do with the clock code. 
I used image controls because I thought they would look better 
than just using a font - one of the reasons was so that the parts 
of the number that are off would still be displayed; like in an LED 
display. 
My program does use the Time function. 
From: mostafa ahmadi 
Date: Wednesday, July 6, 2005 at 04:43:16 
Comments: thank you for every thing.i am from iran,and you can 
count on me for ever.you are a great programmer and i 
say congratulation to you. 
bye 
Martin Allen 1999 - 2011. Last updated Thursday 11 August 2011 07:49:48 PM 
+0100. 
http://www.martin2k.co.uk/vb6/tips/vb_41.php 11/12
8/28/2014 www.martin2k.co.uk/vb6/tips/vb_41.php 
http://www.martin2k.co.uk/vb6/tips/vb_41.php 12/12

More Related Content

Similar to Www.martin2k.co.uk vb6 tips_vb_41

2.3 Apply the different types of algorithm to solve problem
2.3 Apply the different types of algorithm to solve problem2.3 Apply the different types of algorithm to solve problem
2.3 Apply the different types of algorithm to solve problemFrankie Jones
 
TeamXXX_Round1_Pitch_Presentation_Template.pptx
TeamXXX_Round1_Pitch_Presentation_Template.pptxTeamXXX_Round1_Pitch_Presentation_Template.pptx
TeamXXX_Round1_Pitch_Presentation_Template.pptxhannibal9091
 
M150 A Fall2010 T01
M150 A Fall2010 T01M150 A Fall2010 T01
M150 A Fall2010 T01abdalodainat
 
Report for DIGITAL CLOCK 12011042 Manoj.pdf
Report for DIGITAL  CLOCK 12011042 Manoj.pdfReport for DIGITAL  CLOCK 12011042 Manoj.pdf
Report for DIGITAL CLOCK 12011042 Manoj.pdfManojKumar533913
 
Peddle the Pedal to the Metal
Peddle the Pedal to the MetalPeddle the Pedal to the Metal
Peddle the Pedal to the MetalC4Media
 
Begin with c++ Fekra Course #1
Begin with c++ Fekra Course #1Begin with c++ Fekra Course #1
Begin with c++ Fekra Course #1Amr Alaa El Deen
 
Data Science in the Cloud @StitchFix
Data Science in the Cloud @StitchFixData Science in the Cloud @StitchFix
Data Science in the Cloud @StitchFixC4Media
 
ma project
ma projectma project
ma projectAisu
 
Computer programming and networking diploma
Computer programming and networking diplomaComputer programming and networking diploma
Computer programming and networking diplomaKetan Raval
 
XPages Blast - Ideas, Tips and More
XPages Blast - Ideas, Tips and MoreXPages Blast - Ideas, Tips and More
XPages Blast - Ideas, Tips and MoreTeamstudio
 
What’s eating python performance
What’s eating python performanceWhat’s eating python performance
What’s eating python performancePiotr Przymus
 
MITx 6.00.1x Introduction to Computer Science and Programming Using Python - ...
MITx 6.00.1x Introduction to Computer Science and Programming Using Python - ...MITx 6.00.1x Introduction to Computer Science and Programming Using Python - ...
MITx 6.00.1x Introduction to Computer Science and Programming Using Python - ...Dylan-Wu
 
Screencasting and Presenting for Engineers
Screencasting and Presenting for EngineersScreencasting and Presenting for Engineers
Screencasting and Presenting for EngineersKunal Johar
 
Week 4 Assignment - Software Development PlanScenario-Your team has be.docx
Week 4 Assignment - Software Development PlanScenario-Your team has be.docxWeek 4 Assignment - Software Development PlanScenario-Your team has be.docx
Week 4 Assignment - Software Development PlanScenario-Your team has be.docxestefana2345678
 
5_6174859010987000554.pdf
5_6174859010987000554.pdf5_6174859010987000554.pdf
5_6174859010987000554.pdfssuserf39aa4
 
Mythical Man Month Essays on Software Engineering
Mythical Man Month Essays on Software EngineeringMythical Man Month Essays on Software Engineering
Mythical Man Month Essays on Software Engineeringmustafa sarac
 
Introduction to computing Processing and performance.pdf
Introduction to computing Processing and performance.pdfIntroduction to computing Processing and performance.pdf
Introduction to computing Processing and performance.pdfTulasiramKandula1
 

Similar to Www.martin2k.co.uk vb6 tips_vb_41 (20)

2.3 Apply the different types of algorithm to solve problem
2.3 Apply the different types of algorithm to solve problem2.3 Apply the different types of algorithm to solve problem
2.3 Apply the different types of algorithm to solve problem
 
TeamXXX_Round1_Pitch_Presentation_Template.pptx
TeamXXX_Round1_Pitch_Presentation_Template.pptxTeamXXX_Round1_Pitch_Presentation_Template.pptx
TeamXXX_Round1_Pitch_Presentation_Template.pptx
 
M150 A Fall2010 T01
M150 A Fall2010 T01M150 A Fall2010 T01
M150 A Fall2010 T01
 
report
reportreport
report
 
Report for DIGITAL CLOCK 12011042 Manoj.pdf
Report for DIGITAL  CLOCK 12011042 Manoj.pdfReport for DIGITAL  CLOCK 12011042 Manoj.pdf
Report for DIGITAL CLOCK 12011042 Manoj.pdf
 
Peddle the Pedal to the Metal
Peddle the Pedal to the MetalPeddle the Pedal to the Metal
Peddle the Pedal to the Metal
 
Begin with c++ Fekra Course #1
Begin with c++ Fekra Course #1Begin with c++ Fekra Course #1
Begin with c++ Fekra Course #1
 
Data Science in the Cloud @StitchFix
Data Science in the Cloud @StitchFixData Science in the Cloud @StitchFix
Data Science in the Cloud @StitchFix
 
ma project
ma projectma project
ma project
 
Computer programming and networking diploma
Computer programming and networking diplomaComputer programming and networking diploma
Computer programming and networking diploma
 
XPages Blast - Ideas, Tips and More
XPages Blast - Ideas, Tips and MoreXPages Blast - Ideas, Tips and More
XPages Blast - Ideas, Tips and More
 
What’s eating python performance
What’s eating python performanceWhat’s eating python performance
What’s eating python performance
 
ELAVARASAN.pdf
ELAVARASAN.pdfELAVARASAN.pdf
ELAVARASAN.pdf
 
MITx 6.00.1x Introduction to Computer Science and Programming Using Python - ...
MITx 6.00.1x Introduction to Computer Science and Programming Using Python - ...MITx 6.00.1x Introduction to Computer Science and Programming Using Python - ...
MITx 6.00.1x Introduction to Computer Science and Programming Using Python - ...
 
Screencasting and Presenting for Engineers
Screencasting and Presenting for EngineersScreencasting and Presenting for Engineers
Screencasting and Presenting for Engineers
 
Week 4 Assignment - Software Development PlanScenario-Your team has be.docx
Week 4 Assignment - Software Development PlanScenario-Your team has be.docxWeek 4 Assignment - Software Development PlanScenario-Your team has be.docx
Week 4 Assignment - Software Development PlanScenario-Your team has be.docx
 
5_6174859010987000554.pdf
5_6174859010987000554.pdf5_6174859010987000554.pdf
5_6174859010987000554.pdf
 
C# simplified
C#  simplifiedC#  simplified
C# simplified
 
Mythical Man Month Essays on Software Engineering
Mythical Man Month Essays on Software EngineeringMythical Man Month Essays on Software Engineering
Mythical Man Month Essays on Software Engineering
 
Introduction to computing Processing and performance.pdf
Introduction to computing Processing and performance.pdfIntroduction to computing Processing and performance.pdf
Introduction to computing Processing and performance.pdf
 

Www.martin2k.co.uk vb6 tips_vb_41

  • 1. 8/28/2014 www.martin2k.co.uk/vb6/tips/vb_41.php Search Free clock-in/out service razortime.com Perfect for sm all businesses Live tim e sheets, great overview Home | Forums | VB6 | Games | Software | Directory | HTML | Wiki | Blog | Contact Clock Program The Clock program displays the time using big numbers, which resemble those from a digital clock in real life. You can download the source code from here: vb_41_clock.zip (9.3 KB) The compiled program can be downloaded from the Downloads page. Here is how to make it: This program uses the following ActiveX controls: Microsoft Windows Common Controls 6.0 (SP6) (MSCOMCTL.OCX) First, design a Form, which looks similar to this: The Clock Form The Form includes six Image controls (Hour1, Hour2, Min1, Min2, Sec1 and Sec2), four Labels (the colons, one at the bottom for the date http://www.martin2k.co.uk/vb6/tips/vb_41.php 1/12
  • 2. 8/28/2014 www.martin2k.co.uk/vb6/tips/vb_41.php (lblDate) and one on the right of the Form to display 'AM' or 'PM' (lblAMPM)), a Timer (timTime - not displayed above) and an ImageList (ImgNum). The ImageList contains numbers from 1 - 9 and then 0 as images. You can use the ones, included in the source code ZIP file or you can use your own e.g.: ImageList Property Pages To get the Form to be the topmost on the screen, the following API function and constants need to be declared: Private Declare Sub SetWindowPos Lib "User32" (ByVal hWnd As Long, ByVal hWndInsertAfter As Long, ByVal X As Long, ByVal Y As Long, ByVal cx As Long, ByVal cy As Long, ByVal wFlags As Long) Const HWND_TOPMOST = -1 Const SWP_NOACTIVATE = &H10 Const SWP_SHOWWINDOW = &H40 The following code needs to be put into the Form Load event. The centre line sets the window as the topmost window: Private Sub Form_Load() lblDate.Caption = Time & " - " & Format(Date, "Long Date") 'Set window as topmost SetWindowPos hWnd, HWND_TOPMOST, Left / 15, Top / 15, Width / 15, Height / 15, SWP_NOACTIVATE Or SWP_SHOWWINDOW ClockT.Interval = (1 - (Int(Timer) Mod 1)) * 1000 End Sub Here is the code for the Timer: DIGITAL CLOCK IN BULK alibaba.com Choose from 1M+ Verified Suppliers. Contact Directly & Get Live Quotes! http://www.martin2k.co.uk/vb6/tips/vb_41.php 2/12
  • 3. 8/28/2014 www.martin2k.co.uk/vb6/tips/vb_41.php Private Sub timTime_Timer() On Error GoTo Eror Dim t As String, H1 As Integer, H2 As Integer, M1 As Integer, M2 As Integer, S1 As Integer, S2 As Integer t = Time If Len(Time) = 10 Then t = 0 & t t = Replace(t, ":", "") t = Replace(t, " ", "") lblAMPM.Caption = Right(t, 2) t = Replace(t, "PM", "") t = Replace(t, "AM", "") H1 = Mid(t, 1, 1) H2 = Mid(t, 2, 1) M1 = Mid(t, 3, 1) M2 = Mid(t, 4, 1) S1 = Mid(t, 5, 1) S2 = Mid(t, 6, 1) ClockSet Hour1, H1 ClockSet Hour2, H2 ClockSet Min1, M1 ClockSet Min2, M2 ClockSet Sec1, S1 ClockSet Sec2, S2 lblDate.Caption = Format(Date, "Long Date") Exit Sub Eror: If Err = 13 Then MsgBox "This program will only work if you set 'Start, Settings, Control Panel, Regional Settings, Time, Time separator:' to ':' (colon).", 16, "Error" Unload frmClock End Sub This code works by firstly creating a string (t) that the program can work with easily e.g. "9:09:28 PM" would be converted into "090928". Next, the H1, H2, M1, M2, S1 and S2 variables are given values from this string by extracting numbers using the Mid function. Afterwards, the ClockSet function is given each variable and puts the number for it on the Form. The code for the ClockSet function is as follows: Sub ClockSet(Img As Image, Number As Integer) If Number = 0 Then Number = 10 Img.Picture = ImgNum.ListImages.Item(Number).Picture End Sub As the image for '0' is in the number 10 position in the ImageList, the program has to be told to get the image for '0' from this position hence the first line. http://www.martin2k.co.uk/vb6/tips/vb_41.php 3/12
  • 4. 8/28/2014 www.martin2k.co.uk/vb6/tips/vb_41.php The end result should look like this: The Clock Program Additional Information by Martin Allen: To display the time in a different time zone, just change the following code in the timTime_Timer event: t = Time to: t = Time - 12 / 24 The above example will subtract half a day, or 12 hours. The first number can be set to the number of hours you want to add or subtract. E.g. to subtract one hour, change the first number to 1. To add an hour, use '+' instead of '-' and change the first number to 1. http://www.martin2k.co.uk/vb6/tips/vb_41.php 4/12
  • 5. 8/28/2014 www.martin2k.co.uk/vb6/tips/vb_41.php 4 Comments martin2k 1 Login Sort by Best Share Join the discussion… Favorite Riahgrace • 3 years ago .. lisud maN.. kani unTa aKuang e himo sa mU tlE sa compUter.. pro timer nLang aKua.. tHanx sa infO!! :) 1 • Reply • Share › Villasmarlon • 3 years ago the best • Reply • Share › tausif • 3 years ago nice • Reply • Share › Kyle46 • 3 years ago Best download ever!!!!!! • Reply • Share › Subscribe Add Disqus to your site blog comments powered by Disqus Archived Comments From: Gajendra Date: Thursday, December 2, 2010 at 16:45:48 Comments: hi..guys..it's site very useful for us......nict to feel get it....thankyou From: NMSundaram Date: Tuesday, November 30, 2010 at 16:43:13 Comments: Hi..! Very congratulations for your nice clock program and one request for u is that can u help me for going in deep with vb 6.0 & vb.net as i have to be a very good programmer in my life.. Thanks From: Kadir Khan http://www.martin2k.co.uk/vb6/tips/vb_41.php 5/12
  • 6. 8/28/2014 www.martin2k.co.uk/vb6/tips/vb_41.php Date: Wednesday, November 10, 2010 at 16:09:32 Comments: hey dude this site is very helpfull of my major project and u believe my practical marks is 100 to 85..........thans From: Musa Adamu Date: Sunday, January 10, 2010 at 12:55:54 Comments: it was to day 9thjanuary, that i sees this program and its very interested keep it up for more useful codes to all programmers. i wish you the best. From: Pradeep Date: Sunday, November 8, 2009 at 11:45:30 Comments: Fantastic. Thanks so much for sharing the code with others. From: dmash Date: Tuesday, October 6, 2009 at 14:27:00 Comments: this is cool, keep it up. From: abdur Date: Monday, August 24, 2009 at 09:12:12 Comments: It is a very nice idea and programming technique in simple ways it is explainded thanks a lot! From: niranjan Date: Friday, May 1, 2009 at 05:40:06 Comments: Thanks for sharing ur idea and programming knowledge with every1...Carry on .... From: jomar Date: Saturday, September 27, 2008 at 15:57:28 Comments: very... good... po nakuha ko po 2 thanks.. to all/ From: Neo_BeKaBe Date: Monday, September 22, 2008 at 05:53:41 Comments: Great guys...! Thanks so much...! From: king george akom Date: Wednesday, September 17, 2008 at 20:39:14 Comments: how you help people develop their programing skills is the best.continue with the good work From: Waqar Ahmed Bhutto http://www.martin2k.co.uk/vb6/tips/vb_41.php 6/12
  • 7. 8/28/2014 www.martin2k.co.uk/vb6/tips/vb_41.php Date: Wednesday, August 13, 2008 at 09:46:13 Comments: Hi iam sdt of Quest Nawabshah in computer system Engineering,,,, Well your project is amezing.. also i use yours project in my assignments.. thax From: mahantesh Date: Wednesday, April 23, 2008 at 12:39:51 Comments: hi congratulations nice programs From: Shankar Dinkar Patil Date: Sunday, February 10, 2008 at 07:41:14 Comments: that good program in a vb lang. in supo. From: krishna Date: Thursday, January 31, 2008 at 06:49:44 Comments: hi.... its me krishna its been very useful for us to develop our vb knowledge... neway keep ,ur works move From: mjohn Date: Wednesday, January 30, 2008 at 05:28:53 Comments: hi, I'm a newbie in vb programming i like your programs.. And right now i'm studying the way you code i need to learn vb6.0 for my projects thanks for sharing your vb projects.. From: kaustubh Date: Tuesday, January 29, 2008 at 07:45:07 Comments: its interesting the codes From: Brentan Date: Friday, October 19, 2007 at 10:09:22 Comments: for some reason when i tried to create my own clock using your code the line: Img.Picture = ImgNum.ListImages.Item(Number).Picture always comes up as method or data member not found. need help Reply: Have you named your ImageList control ImgNum? Is the argument 'Img' present in your 'ClockSet' procedure? http://www.martin2k.co.uk/vb6/tips/vb_41.php 7/12
  • 8. 8/28/2014 www.martin2k.co.uk/vb6/tips/vb_41.php Have a look at the source code to compare it to yours. From: ahmad dukku Date: Tuesday, September 11, 2007 at 13:28:18 Comments: its interesting the codes From: Nurudeen Date: Saturday, August 25, 2007 at 01:00:15 Comments: I love this stuff the code are important to me. What makes a programmer if he/she don't know how to write programmes or develop softward From: dhondhoncraze Date: Wednesday, August 1, 2007 at 04:53:23 Comments: Hey your work is nice, but it is very simple, i can make that one in just few minute; by the way i'm a programmer also; keep up the good work; your great!!!!!!!!!!!!!!! From: nadeem arain Date: Monday, July 30, 2007 at 15:03:36 Comments: this is a nice clock +923003238138 From: AMEER Date: Friday, June 8, 2007 at 13:03:10 Comments: You coding intuitiveness is so much helpful for all level of programmers. Thanks a lot. May you think of more such codes. From: sanela Date: Friday, June 1, 2007 at 12:21:22 Comments: hello i write from bosnia and herzegovina i have school asigment i have to make some simple program in Visual Basic, i dont know have,i dont have any litherature,and i cant download any of this programs,i really like clock program it looks great, byyy sanela From: sachin nimkar Date: Wednesday, May 2, 2007 at 08:10:46 Comments: your clock program is cooool iwant another also From: phani Date: Friday, April 6, 2007 at 15:26:31 http://www.martin2k.co.uk/vb6/tips/vb_41.php 8/12
  • 9. 8/28/2014 www.martin2k.co.uk/vb6/tips/vb_41.php Comments: clock program is very nice. From: ardie Date: Tuesday, April 3, 2007 at 03:32:26 Comments: hello... i like ur program its very nice.... ur the best programer ive ever scne... good luck /// From: Umair Date: Friday, March 23, 2007 at 11:50:39 Comments: i'm from england, gr8 work man, it can be even greater if u cud add alarm to it, in order to alarm the user about n e special event. Reply: All you would need to do is to test whether the current time matches the time you want an event to occur e.g. you could try the following code in the timTime_Timer() event. Make sure you declare a Boolean variable called Alarm. ... lblAMPM.Caption = Right(t, 2) If Alarm = False Then If t = "080000AM" Then Alarm = True Shell "C:Program FilesWindows Media Playerwmplayer.exe c:music.mp3", vbNormalFocus End If End If If t = "080001AM" Then Alarm = False t = Replace(t, "PM", "") ... From: Anil kumar Date: Tuesday, January 9, 2007 at 12:21:11 Comments: Hi, this is anil...I am from Bangalore[India].I am doing my final year computer science. About ur clock Program,it is wonderfull. I am in need help.can u help me. How to get quick knowlege in vb? Regards [Anil Kumar) From: syefriadi Date: Friday, January 5, 2007 at 03:22:08 Comments: I am very glad to follow your website and your source http://www.martin2k.co.uk/vb6/tips/vb_41.php 9/12
  • 10. 8/28/2014 www.martin2k.co.uk/vb6/tips/vb_41.php code. From: joginder kumar Date: Monday, December 11, 2006 at 08:56:04 Comments: Hi I am indian !!. very congatulations for ur nice clock programm and one request for u is that can u help me for going in deep with vb 6.0 & vb.net as i have to be a very good programmer in my life.. Thanks From: Rehan Shah Date: Thursday, November 30, 2006 at 17:22:32 Comments: I m from Karachi.It is really nice work .I want to be a VB Programmer in future. I used these programs and i found them excellent. If u have any new project so email i need to learn. From: Irudaya Raja Date: Monday, November 13, 2006 at 14:59:48 Comments: Hai! I am an Indian. I am very glad to follow your website and your source code. This Clock theme is very useful for me. From: Clydlanne Date: Friday, September 29, 2006 at 07:40:51 Comments: Hi! I am a 3rd year BSCS student. Well, you have a nice program. Keep the good work. Your clock program is really perfect! Bye! Have a nice day! From: arun <bindasaks2005@!gmail.com> Date: Thursday, September 14, 2006 at 13:36:37 Comments: wonderful From: Santosh Yadav Date: Tuesday, August 29, 2006 at 07:49:56 Comments: Hi, I m from India.It is really nice work .I want to be a VB Programmer too. Hope you can help me (i u wish). Bye From: omkar kanitkar Date: Thursday, February 2, 2006 at 06:54:45 Comments: i am indian, now in russia (for education). i have simpler codes for the same clock program. but still i need some help in creating other projects. so pls e mail me your e mail address(if you wish to help). thanks. http://www.martin2k.co.uk/vb6/tips/vb_41.php 10/12
  • 11. 8/28/2014 www.martin2k.co.uk/vb6/tips/vb_41.php From: rafay ikram Date: Saturday, January 28, 2006 at 18:47:01 Comments: i used these programs and i found them excellent thanx for these programs From: Pepe Rojas Date: Tuesday, November 29, 2005 at 20:05:46 Comments: Hi, ¿do you speak spanish?, I'm from México. My english is not good, but I will try to use it. My question is: Why you need APIs and, image control and OCX, if you can do it with a text box with a font like LCD o some similar. and calling the function TIME, is more easy and the file is more light. Later I will send you my version of clock to you put it on your web. If you can, send me the answer to my mail. Pepe. Reply: The API function is used to keep the window above others - it does not have anything to do with the clock code. I used image controls because I thought they would look better than just using a font - one of the reasons was so that the parts of the number that are off would still be displayed; like in an LED display. My program does use the Time function. From: mostafa ahmadi Date: Wednesday, July 6, 2005 at 04:43:16 Comments: thank you for every thing.i am from iran,and you can count on me for ever.you are a great programmer and i say congratulation to you. bye Martin Allen 1999 - 2011. Last updated Thursday 11 August 2011 07:49:48 PM +0100. http://www.martin2k.co.uk/vb6/tips/vb_41.php 11/12