Results 1 to 10 of 10

Thread: date (maybe a label?)

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    14

    date (maybe a label?)

    alright, i'm a noob to vb, this is the first forum i found, and if this is in the wrong section i'll move/delete it.

    i'm trying to get the current date to show up on my application (it's going to be a shift log). i don't want to use the date picker, i am hoping i can just have it displayed in a 'label', or something nice and simple looking.

    any help would be great.

  2. #2
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: date (maybe a label?)

    Welcome to the forums!

    Piece of cake. Add a label, call it something pretty, like lblDate... then whenever you need the current date, in the code just add:
    vb Code:
    1. lblDate.Text = System.DateTime.Now.ToString()

    Instant date!

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

    Re: date (maybe a label?)

    For your info Zero Skill,

    You can also format exactly how the date will be displayed. Here are a few examples:
    vb Code:
    1. 'Full day/month name with / character: format of Day/Month/Year
    2.         Me.Label1.Text = Date.Now.ToString("dddd/MMMM/yyyy")
    3.  
    4.         'Numerical day/month with - character: format of day/month/year
    5.         Me.Label1.Text = Date.Now.ToString("dd - MM - yyyy")
    6.  
    7.         'numerical short day/month/year: format of Month/Day/Year
    8.         Me.Label1.Text = Date.Now.ToString("MM/dd/yy")
    Stim

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

  4. #4

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    14

    Re: date (maybe a label?)

    Quote Originally Posted by timeshifter
    Welcome to the forums!

    Piece of cake. Add a label, call it something pretty, like lblDate... then whenever you need the current date, in the code just add:
    vb Code:
    1. lblDate.Text = System.DateTime.Now.ToString()

    Instant date!
    thanks for the code. now if i could just get it to work (man i hate being the dumb new guy).

  5. #5
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: date (maybe a label?)

    We all start somewhere, so don't worry about it.

    I might make this offer to too many people... but if you use AIM or MSN, check my profile and hit me up if you need help. I'm usually online and always willing to help.

  6. #6

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    14

    Re: date (maybe a label?)

    Quote Originally Posted by timeshifter
    We all start somewhere, so don't worry about it.

    I might make this offer to too many people... but if you use AIM or MSN, check my profile and hit me up if you need help. I'm usually online and always willing to help.
    thanks for the offer. I got it working... i guess i have to click on it to change from text to the datetime. i changed _click to _load but that didn't make a difference.

  7. #7
    Banned timeshifter's Avatar
    Join Date
    Mar 2004
    Location
    at my desk
    Posts
    2,465

    Re: date (maybe a label?)

    Did you try the Form_Load event?

  8. #8

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    14

    Re: date (maybe a label?)

    Quote Originally Posted by timeshifter
    Did you try the Form_Load event?
    Event 'Form_Load' cannot be found.

  9. #9
    Addicted Member
    Join Date
    Jan 2007
    Posts
    143

    Re: date (maybe a label?)

    Quote Originally Posted by Zero Skill
    Event 'Form_Load' cannot be found.
    go back to the designer, and create it

    you create it by double clicking the form's title bar... or by selecting the form and viewing the properties, clicking the lightning bolt (events) button, and double click the empty space next to form load.

    I could probably offer some help too... I'm not a guru, but I have the main idea of how to get things accomplished (whether or not it is the "Proper" way... I tend to create tons of variables where arrays could be used, and use un nesscesserry logic)... I was just like you not too long ago. I'll add my IM and MSN to my profile, feel free to contact me whenever I'm online

    After a few weeks with VB, you should really be quite good at it (well, not the SQL side, but that's a whole other story). It's basically this.that.blah = something.else * 8... everything is easy to remember because they use simple properties... text, size, color... They are what they say. Oh... play around with CTRL + Space Bar... when you are typing your code, it can really help you fine the property/attribute that you need
    Last edited by rbxslvr; May 1st, 2007 at 07:57 PM.

  10. #10

    Thread Starter
    New Member
    Join Date
    May 2007
    Posts
    14

    Re: date (maybe a label?)

    i am an idiot.
    i was double clicking on the label, then putting the code in the label's sub. this time, i put it in the form's sub and it worked like a freaking charm!

    thanks everyone for the help.
    is this the proper section to ask general questions like this? my first project is a shiftlog for a small business, and i'm sure i'll have a million other questions.
    thanks again.
    0skill
    Last edited by Zero Skill; May 1st, 2007 at 08:22 PM.

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