Results 1 to 6 of 6

Thread: datetime.addminutes

  1. #1

    Thread Starter
    Fanatic Member Crash893's Avatar
    Join Date
    Dec 2005
    Posts
    930

    datetime.addminutes

    I cant seem to figure this one out

    I have a trackbar that i need to slide back and forth to adjust the time of a datetime object.

    but even thought I have a Int in the value to add it still doesn't seem to do anything


    can anyone see where I'm messing up?

    C# Code:
    1. DateTime CDeadline = new DateTime();
    2.         private void Track_Current_Scroll(object sender, EventArgs e)
    3.         {
    4.             // MessageBox.Show(Convert.ToString(Track_Current.Value * 10));  <--- displays the correct value
    5.             CDeadline.AddMinutes(Track_Current.Value * 10); <---- does not work
    6.             CDeadline.AddMinutes(1234); <--- static test still doesnt work
    7.  
    8.             lbl_Current_time.Text = CDeadline.ToString("HH:mm");
    9.            
    10.         }
    Last edited by Crash893; Jul 8th, 2008 at 10:37 PM.

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: datetime.addminutes

    The answer to your question is in the MSDN documentation for the method:
    Quote Originally Posted by MSDN
    This method does not change the value of this DateTime. Instead, a new DateTime is returned whose value is the result of this operation.
    You must have missed that bit when you read it. You did read it, didn't you? Of course you did. Reading the documentation for a method is obviously the first thing you should do when you call it and it doesn't behave as you expect. I guess you must have just not read it carefully enough. You won't make that mistake again, will you?
    Last edited by jmcilhinney; Jul 8th, 2008 at 10:59 PM.
    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

  3. #3

    Thread Starter
    Fanatic Member Crash893's Avatar
    Join Date
    Dec 2005
    Posts
    930

    Re: datetime.addminutes

    Figured it out :

    Cdeadline =CDeadline.AddMinutes(Track_Current.Value * 10);


    1) I was searching but as I've said before if I don't find it right away I don't see the harm in posting it here as a question that's what this forum is for. If / when I find the answer I always post what I’ve found back into my own post for anyone else that has the same question. If no one had any questions I wouldn't say this forum wouldn't exist but it would be pretty empty.

    2) I figure that if I have a question that others might have the same question and there for it’s not a huge insult to humanity to post it here where it can in turn be goggled and answer someone else question. (Which is how I found the answer (different forum though))

    3) I see this lot on other forums where one or two guys will answer all the questions but also at the same time become pretty "peeved" about having to answer all the questions. I can total sympathize i do the same thing on a forum for car repair., and please please don't take this the wrong way you have helped me more times than I care to count and I think your reputation speaks for itself but don't feel that anyone is twisting your arm to answer.

    Again I mean no insult but I don't think rhetorically asking me why I didn't check the documentation (when you so clearly want to scream RTFM) is not really the answer to my question.

    but then again if you got to vent then go ahead

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: datetime.addminutes

    But why were you searching? This is what I don't get. People say they can't find information because they don't look properly. First up, you should be using the local MSDN Library unless you have a good reason not to. In VS you select Help -> Index. That takes you straight to the index and you type datetime.addminutes into the "Look for:" box. By the time you get to datetime.addmin the correct item is at the top of the topic list. You then just click it to go straight to the topic specifically for the method you're using. You read and you get your answer. There's absolutely no reason to be searching anywhere, so there's absolutely no reason to not find the information you need. Even if you do need to use the online library for some reason, you simply "search" for datetime.addminutes and the same topic will be the first result.

    I don't get peeved at having to answer all the questions. I like answering the questions. What I get peeved at is people who apparently want to be software developers holding themselves back by not doing something as simple as reading documentation. I want to see everyone who posts here be as good as they can be and that's never going to happen if they can't find information for themselves.

    Maybe you didn't realise that every type and member has a topic dedicated to it so, rather than searching, you can just go straight to that topic. I didn't when I first started out. I always used the MSDN documentation as my first source of information though, so it didn't take me long to work it out. If everyone else did the same thing then THEY would be the ones to benefit, NOT me. THAT is why I make posts like these. I hope that it will be taken by people as a proverbial slap in the back of the head and used as motivation to do the simple things for themselves and, as a result, become better developers. I don't really care if I come off as arrogant or whatever in the process. I post here to help people become better developers. Sometimes the best way to do that is not necessarily to answer the question that was asked. If the next time you have a similar question you read the appropriate documentation and can solve the problem yourself, I will have succeeded.

    You're welcome.
    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

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: datetime.addminutes

    By the way, let's not forget that you could have just clicked the method name and pressed F1. Even easier.
    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

  6. #6

    Thread Starter
    Fanatic Member Crash893's Avatar
    Join Date
    Dec 2005
    Posts
    930

    Re: datetime.addminutes

    Quote Originally Posted by jmcilhinney
    By the way, let's not forget that you could have just clicked the method name and pressed F1. Even easier.

    that i actually didn't know and point taken

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