#1
  1. Standing 3 feet to the left.
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jan 2006
    Location
    USA
    Posts
    1,435
    Rep Power
    185

    (Solved?) [VB.NET] ParseExact formats not matching when they should


    Working on making a timer that will read from an XML file, find a list of times when to do something, calculate the time interval from now until the next time in the list, then enable the Timer.

    The XML takes in a list of times, separated by comma, in military format (i.e. 1400 instead of 2:00 PM). For some reason, this is failing for all single-digit hours (900 (9:00 AM) and previous), even when using the H parameter. The particular line, which I wish was tangible so I could throw it against a wall, is
    VB.net Code:
    dtRefreshTime = DateTime.ParseExact(gblRefreshValues(index).ToString, "Hmm", Nothing)

    Testing with the H:mm format makes it work just fine; it seems that without the colon, VB.net tries to format the "90" as the hour. However, gblRefreshValues can also hold time intervals, so I'd prefer to keep it as an integer. Is there a way to fix this using a string that's strictly numbers?
    Last edited by Tukaro; January 5th, 2012 at 02:51 PM. Reason: Removed random [
    I'd rather teach you to fish than give you a fish. I reserve the right to also slap you with the fish.
  2. #2
  3. Standing 3 feet to the left.
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jan 2006
    Location
    USA
    Posts
    1,435
    Rep Power
    185
    It appears this also happens when using "h", as well. Is there a way to force it to read the date in reverse?
    I'd rather teach you to fish than give you a fish. I reserve the right to also slap you with the fish.
  4. #3
  5. Standing 3 feet to the left.
    Devshed Beginner (1000 - 1499 posts)

    Join Date
    Jan 2006
    Location
    USA
    Posts
    1,435
    Rep Power
    185
    Since I'm trying to get this out the door, I just changed the array to a string so that when the user puts in "0900", the leading 0 isn't truncated. I'll handle Int conversion when it's necessary.

    Also, if anyone thinks about trying it, writing in reverse, "mmH" (to get the mm first) doesn't work; it seems to want to pull the least exact number (the hour) first.

    If anyone knows what string to feed the function, I'd still like to know, though. Could be useful in the future.
    I'd rather teach you to fish than give you a fish. I reserve the right to also slap you with the fish.

IMN logo majestic logo threadwatch logo seochat tools logo