Results 1 to 7 of 7

Thread: [RESOLVED] subtracting one-second intervals from a timespan variable?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Resolved [RESOLVED] subtracting one-second intervals from a timespan variable?

    I have a TimeSpan variable in which I need to subtract 1 second from it but not sure how to do it? The value is the TimeSpan variable is set and then a Timer control is used to decrement the variable by 1 second intervals.

    Thanks,
    Blake

  2. #2
    Sinecure devotee
    Join Date
    Aug 2013
    Location
    Southern Tier NY
    Posts
    6,582

    Re: subtracting one-second intervals from a timespan variable?

    variable -= TimeSpan.FromSeconds(1)

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: subtracting one-second intervals from a timespan variable?

    Thanks passel...that worked great!
    Blake

  4. #4
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,754

    Re: [RESOLVED] subtracting one-second intervals from a timespan variable?

    Quote Originally Posted by blakemckenna View Post
    I have a TimeSpan variable in which I need to subtract 1 second from it but not sure how to do it? The value is the TimeSpan variable is set and then a Timer control is used to decrement the variable by 1 second intervals.

    Thanks,
    Are you aware that this approach is less accurate than others? If this is for short periods it will not matter, or maybe a few seconds is unimportant.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  5. #5

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: [RESOLVED] subtracting one-second intervals from a timespan variable?

    I've tested it and it works perfectly for what I'm doing...

    If there is a better way, I'm all ears! I'm always trying to find better and more efficient ways of doing something.
    Blake

  6. #6
    Powered By Medtronic dbasnett's Avatar
    Join Date
    Dec 2007
    Location
    Jefferson City, MO
    Posts
    9,754

    Re: [RESOLVED] subtracting one-second intervals from a timespan variable?

    Quote Originally Posted by blakemckenna View Post
    I've tested it and it works perfectly for what I'm doing...

    If there is a better way, I'm all ears! I'm always trying to find better and more efficient ways of doing something.
    Here http://www.vbforums.com/showthread.p...=1#post4845569 is an example that does a count down.
    My First Computer -- Documentation Link (RT?M) -- Using the Debugger -- Prime Number Sieve
    Counting Bits -- Subnet Calculator -- UI Guidelines -- >> SerialPort Answer <<

    "Those who use Application.DoEvents have no idea what it does and those who know what it does never use it." John Wein

  7. #7

    Thread Starter
    PowerPoster
    Join Date
    Jan 2004
    Location
    Southern California
    Posts
    5,034

    Re: [RESOLVED] subtracting one-second intervals from a timespan variable?

    Thanks db...
    Blake

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