Results 1 to 9 of 9

Thread: [RESOLVED] displaying system date and time

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    255

    Resolved [RESOLVED] displaying system date and time

    hello,

    could anyone tell me how to display the system date and time in a label?
    i would like to do it so when a user logs on the labels text changes to display the users name and the date and time that they logged in!
    thank you,

    iain

  2. #2
    Frenzied Member stimbo's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    1,739

    Re: displaying system date and time

    In the form load event just put:
    vb Code:
    1. Me.Label1.Text = Date.Now.Tostring

    You can also mess around with the toString bit and use it to format the date/time
    Stim

    Free VB.NET Book Chapter
    Visual Basic 2005 Cookbook Sample Chapter

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    255

    Re: displaying system date and time

    yeah thats got it!
    thanks a lot

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    255

    Re: displaying system date and time

    1 other thing,
    how do i get it so it displays the persons name before it?

    i tried.....

    me.lblfeedback.text = '" & Name & "' Logged in Date.Now.ToString

    it didnt like it!

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    255

    Re: displaying system date and time

    oooh i got it.......

    lblfeedback.text = (" " & Name & " Logged in ") & date.now.tostring

    thanks for putting me on the right track Stimbo!!!!!!!

  6. #6
    Frenzied Member stimbo's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    1,739

    Re: [RESOLVED] displaying system date and time

    I think this might be it:

    vb Code:
    1. me.lblfeedback.text = System.Environment.UserName & "  Logged in at: " & date.now.tostring
    Stim

    Free VB.NET Book Chapter
    Visual Basic 2005 Cookbook Sample Chapter

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    255

    Re: [RESOLVED] displaying system date and time

    how would i get it so the clock refreshes and constantly displays the correct time?

  8. #8
    Frenzied Member stimbo's Avatar
    Join Date
    Jun 2006
    Location
    UK
    Posts
    1,739

    Re: [RESOLVED] displaying system date and time

    Add a timer to your project, enable it and in the tick event put the code you have
    Stim

    Free VB.NET Book Chapter
    Visual Basic 2005 Cookbook Sample Chapter

  9. #9

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    255

    Re: [RESOLVED] displaying system date and time

    cheers, i should have thought of that!!

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