Results 1 to 7 of 7

Thread: Current Date/Time in Custom ToolStripStatusLabel

  1. #1

    Thread Starter
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Current Date/Time in Custom ToolStripStatusLabel

    This custom status label incorporates its own Timer and displays the current date and/or time updated every second. You set the display format in the same way as for a DateTimePicker. Nothing ground-breaking but handy. Also a good way for beginners to see how to display the date and/or time in a control.

    Note that the attached code was originally written in C# and was converted using Instant VB from Tangible Software Solutions.
    Attached Files Attached Files
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  2. #2
    New Member
    Join Date
    Mar 2007
    Posts
    1

    Re: Current Date/Time in Custom ToolStripStatusLabel

    Hi, i read your topics and you seems to be really awesome.
    I need your help please:
    How can i display the system time on my visual basic 6 forms?
    HOw can i use your code if it can work with Visual Basic?
    I am not good into visual basic, i am engineer in machines where i use assembler and PLC, this is my first project i have in Visual basic 6 and i need to add the time on it so that the machine operator can be able to see the time while working
    I appreciate any help you can provide,
    Thanks,
    Mashuli

  3. #3

    Thread Starter
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Current Date/Time in Custom ToolStripStatusLabel

    Quote Originally Posted by Mashuli
    Hi, i read your topics and you seems to be really awesome.
    I need your help please:
    How can i display the system time on my visual basic 6 forms?
    HOw can i use your code if it can work with Visual Basic?
    I am not good into visual basic, i am engineer in machines where i use assembler and PLC, this is my first project i have in Visual basic 6 and i need to add the time on it so that the machine operator can be able to see the time while working
    I appreciate any help you can provide,
    Thanks,
    Mashuli
    If you have a question regarding VB6 then you should ask it in the Classic VB forum, which for VB6 and earlier. I've never used VB6 but I can tell you that there's a Now function that will return the current date and time and a Format function that allows you to format a string. They work in very similar ways to Date.Now and String.Format in VB.NET. I have no idea how to do the equivalent of a Timer in VB6, but that's what the Classic VB forum is for: to ask those sorts of questions.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  4. #4
    Hyperactive Member jazFunk's Avatar
    Join Date
    Dec 2008
    Location
    Palm Harbor
    Posts
    407

    Re: Current Date/Time in Custom ToolStripStatusLabel

    I'd like to use this in my app. Is this OK?

    If so, how do I use it?

    The .vb file has been added to my project.

    I used an imports statement in the form I want to use it on. But I'm lost from there.
    Things I've found useful:
    DateTime.ToString() Patterns | Retrieving and Saving Data in Databases | ADO.NET Data Containers: An Explanation

    Quote of the day from jmcilhinney:
    'Talking about Option Strict and Option Explicit in the same sentence is pointless unless it is to say that they should both be On.'

  5. #5
    Hyperactive Member jazFunk's Avatar
    Join Date
    Dec 2008
    Location
    Palm Harbor
    Posts
    407

    Re: Current Date/Time in Custom ToolStripStatusLabel

    I jumped the gun. Been beating my head against this all morning. Right after I posted this I figured it out.

    vb Code:
    1. Dim dtStrip As New ToolStripDateTimeStatusLabel
    2.         dtSTrip.Available = True
    3.         dtSTrip.Owner = Me.StatusStrip
    Things I've found useful:
    DateTime.ToString() Patterns | Retrieving and Saving Data in Databases | ADO.NET Data Containers: An Explanation

    Quote of the day from jmcilhinney:
    'Talking about Option Strict and Option Explicit in the same sentence is pointless unless it is to say that they should both be On.'

  6. #6

    Thread Starter
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,222

    Re: Current Date/Time in Custom ToolStripStatusLabel

    Quote Originally Posted by jazFunk View Post
    I jumped the gun. Been beating my head against this all morning. Right after I posted this I figured it out.

    vb Code:
    1. Dim dtStrip As New ToolStripDateTimeStatusLabel
    2.         dtSTrip.Available = True
    3.         dtSTrip.Owner = Me.StatusStrip
    If you've added the class to your project and built it then you should be able to add an instance to your StatusStrip in the designer, just as you would any other status strip item. It's a long time since I used this class but I'm fairly sure that was the case.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  7. #7
    Hyperactive Member jazFunk's Avatar
    Join Date
    Dec 2008
    Location
    Palm Harbor
    Posts
    407

    Re: Current Date/Time in Custom ToolStripStatusLabel

    Quote Originally Posted by jmcilhinney View Post
    If you've added the class to your project and built it then you should be able to add an instance to your StatusStrip in the designer, just as you would any other status strip item. It's a long time since I used this class but I'm fairly sure that was the case.

    The reason I couldn't add it in the designer was because I didn't build it once I added the class.

    After reading your post, I checked the designer and sure enough it was there.
    Things I've found useful:
    DateTime.ToString() Patterns | Retrieving and Saving Data in Databases | ADO.NET Data Containers: An Explanation

    Quote of the day from jmcilhinney:
    'Talking about Option Strict and Option Explicit in the same sentence is pointless unless it is to say that they should both be On.'

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width