|
-
Oct 1st, 2005, 12:02 PM
#1
Thread Starter
Junior Member
[RESOLVED] Date format question
How would I get a label box to just display the current year?
Thanks
Aaron
-
Oct 1st, 2005, 12:06 PM
#2
Re: Date format question

VB Code:
Option Explicit
Private Sub Form_Load()
Label1.Caption = Year(Date)
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Oct 1st, 2005, 12:07 PM
#3
Thread Starter
Junior Member
Re: Date format question
That was hard :-p, thanks a lot .
-
Oct 1st, 2005, 12:09 PM
#4
Frenzied Member
Re: [RESOLVED] Date format question
koolzap351:
The following code will put the current date into a text box when you click on the text box:
Private Sub txtDate_Click()
If txtDate.Text <> CStr(Date) Then
txtDate.Text = Date
End If
End Sub
If you want to have the date appear in the text box when the form loads, then put this code in the form_load event instead of the txtDate_Click event.
This code will put the current time into a text box when you click on the text box:
Private Sub txtTime_Click()
If txtTime.Text <> CStr(Time) Then
txtTime.Text = Time
End If
End Sub
Again, if you want the time to appear in the text box when the form is loaded this code need to be in the form_load event.
This should work.
-
Oct 1st, 2005, 12:09 PM
#5
Re: [RESOLVED] Date format question
I know. I almost tired myself out for the day. 
Btw, its just called a Label control and not a Label Box.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|