Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. Visual Basic
  4. display date and time in label

display date and time in label

Scheduled Pinned Locked Moved Visual Basic
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jds1207
    wrote on last edited by
    #1

    I am trying to display the current date and time in a label. Here is my code: Dim rightNow As DateTime = DateTime.Now datetime.Text = String.Format("{0:d)", rightNow) & String.Format("{0:T)", rightNow) This code works in my other two applications but this time it underlines DateTime.Now and says Now is not a member of System.Windows.Forms.Label. Any ideas?

    J M 2 Replies Last reply
    0
    • J jds1207

      I am trying to display the current date and time in a label. Here is my code: Dim rightNow As DateTime = DateTime.Now datetime.Text = String.Format("{0:d)", rightNow) & String.Format("{0:T)", rightNow) This code works in my other two applications but this time it underlines DateTime.Now and says Now is not a member of System.Windows.Forms.Label. Any ideas?

      J Offline
      J Offline
      JUNEYT
      wrote on last edited by
      #2

      If datetime is a label or a text, it doesn't have any property named as NOW. Now indicates the date and time for now. It is a function. :wtf: Dim myLabel as new label label.text = Now.toString

      What a curious mind needs to discover knowledge is noting else than a pin-hole.

      J 1 Reply Last reply
      0
      • J JUNEYT

        If datetime is a label or a text, it doesn't have any property named as NOW. Now indicates the date and time for now. It is a function. :wtf: Dim myLabel as new label label.text = Now.toString

        What a curious mind needs to discover knowledge is noting else than a pin-hole.

        J Offline
        J Offline
        jds1207
        wrote on last edited by
        #3

        I found out what the problem was. Here is my code: Dim rightNow As DateTime = DateAndTime.Now lbltime.Text = String.Format("{0:T}", rightNow) lbldate.Text = String.Format("{0:d}", rightNow) Thanks for the help! jds1207

        1 Reply Last reply
        0
        • J jds1207

          I am trying to display the current date and time in a label. Here is my code: Dim rightNow As DateTime = DateTime.Now datetime.Text = String.Format("{0:d)", rightNow) & String.Format("{0:T)", rightNow) This code works in my other two applications but this time it underlines DateTime.Now and says Now is not a member of System.Windows.Forms.Label. Any ideas?

          M Offline
          M Offline
          M Hall
          wrote on last edited by
          #4

          It looks like you named your label the same name as the function, visual basic is not case sensitive, try renaming your label

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups