![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Programmer
Join Date: Jan 2008
Posts: 9
Rep Power: 0
![]() |
Visual Basic Current Time On Form
How do I show the current time on the form in a label, and update it every second or maybe every minute???
I put "lblTime.Text = DateTime.Now" into a OnClick sub, but that only works when I click it... how do I get it to change every few seconds, or minute????? also How can I at the same time on another label make a timer that counts up continuously from when the application loads? thanks -S_E |
|
|
|
|
|
#2 |
|
Man Bear Pig Hunter
Join Date: Jul 2005
Location: NorCal, USA
Posts: 295
Rep Power: 4
![]() |
Re: Visual Basic Current Time On Form
lblTime.Text = DateTime.Now.Minute.ToString() Your best bet is use a timer to tick every minute and run that little bit of code. |
|
|
|
|
|
#3 |
|
Programmer
Join Date: Jan 2008
Posts: 9
Rep Power: 0
![]() |
Re: Visual Basic Current Time On Form
ok, I guess I forgot to mention this. I'm a VB newbie.
This would be done how? |
|
|
|
|
|
#4 |
|
Code Poet
Join Date: Feb 2008
Location: Sydney, Nova Scotia (Canada)
Posts: 5
Rep Power: 0
![]() |
Re: Visual Basic Current Time On Form
There is a timer object you can add to the form, it should be a little stop watch-like looking icon on the tools side bar. After adding it, set the interval to the number of miliseconds you want the timer to iterate itself (in this case, 1000 for one second, or 60000 for a minute).
The code you want executed goes inside of the timer itself. |
|
|
|
|
|
#5 |
|
Programmer
|
Re: Visual Basic Current Time On Form
I made a computer calander for someone not long ago, I think you may find the code helpful for what you're looking for , here is the entire code from the 1 I made
How to set or fill out the Properties: Form Name Calendar: Caption = My Computer Calendar BorderStyle = 1 - Fixed Single Timer1 Timer1: Interval = 1000 Label1 Name Day: BackStyle = 0 - Transparent Caption = Sunday FontName = Times New Roman FontBold = True FontSize = 24 Label2 Name Time: BackStyle = 0 - Transparent Caption = 00:00:00 PM FontName = Times New Roman FontBold = True FontSize = 24 Label3 Name Year: BackStyle = 0 - Transparent Alignment = 2 - Center Caption = 2008 FontName = Times New Roman FontBold = True FontSize = 24 Label4 Number: BackStyle = 0 - Transparent Alignment = 2 - Center Caption = 30 FontName = Arial FontBold = True FontSize = 72 Label5 Month: BackStyle = 0 - Transparent Alignment = 2 - Center Caption = March FontName = Times New Roman FontBold = True FontSize = 24 Now for the Code: General Declarations: timDisplay Timer Event: Private Sub Timer1_Timer() Dim Today As Variant Today = Now Day.Caption = Format(Today, "dddd") Month.Caption = Format(Today, "mmmm") Year.Caption = Format(Today, "yyyy") Number.Caption = Format(Today, "d") Time.Caption = Format(Today, "h:mm:ss ampm") End Sub |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Visual Basic to java HELP! | araujo2nd | Visual Basic .NET | 1 | Feb 13th, 2008 9:36 AM |
| Visual Basic Admin Input | kewlgeye | Visual Basic | 0 | Jan 23rd, 2008 11:14 AM |
| visual basic pixel image comparison | youngnoviceinneedofhelp | Visual Basic | 3 | Mar 19th, 2006 1:57 PM |
| Visual Basic 6.0 Form Effects | fox123 | Visual Basic | 7 | Dec 21st, 2005 7:03 AM |
| Enquiry About Visual Basic Project | kbkhoo5053 | Visual Basic | 13 | Feb 15th, 2005 2:20 AM |