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
  1. Home
  2. General Programming
  3. Visual Basic
  4. Stupid VB glitch

Stupid VB glitch

Scheduled Pinned Locked Moved Visual Basic
questionlounge
3 Posts 2 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.
  • K Offline
    K Offline
    Kevnar
    wrote on last edited by
    #1

    ... intDy = Int(lngCs / 86400) ' lngCS = 404090, intDy = 4 lngCs = lngCs - (intDy * 86400) ' no overflow, lngCs = 58490 intHr = Int(lngCs / 3600) ' intHr = 16 lngCs = lngCs - (intHr * 3600) ' overflow here, WTF?!? ... How come the VB runtime can process int * 86400 but when it tries to multiply int * 3600 it gets an overflow? Is this just completely insane, or am I missing something?

    "You only disagree because you're a moron. If you were a man of intelligence you would see that I'm obviously right." - The General Consensus

    G 1 Reply Last reply
    0
    • K Kevnar

      ... intDy = Int(lngCs / 86400) ' lngCS = 404090, intDy = 4 lngCs = lngCs - (intDy * 86400) ' no overflow, lngCs = 58490 intHr = Int(lngCs / 3600) ' intHr = 16 lngCs = lngCs - (intHr * 3600) ' overflow here, WTF?!? ... How come the VB runtime can process int * 86400 but when it tries to multiply int * 3600 it gets an overflow? Is this just completely insane, or am I missing something?

      "You only disagree because you're a moron. If you were a man of intelligence you would see that I'm obviously right." - The General Consensus

      G Offline
      G Offline
      Glenn Dawson
      wrote on last edited by
      #2

      86400 is treated as a Long while 3600 is treated as an Integer In the first case, the temporary is stored in a Long. The temporary result of the second one is stored in an Integer causing an overflow. Try: lngCs = lngCs - (intHr * CLng(3600))

      K 1 Reply Last reply
      0
      • G Glenn Dawson

        86400 is treated as a Long while 3600 is treated as an Integer In the first case, the temporary is stored in a Long. The temporary result of the second one is stored in an Integer causing an overflow. Try: lngCs = lngCs - (intHr * CLng(3600))

        K Offline
        K Offline
        Kevnar
        wrote on last edited by
        #3

        Yeah. I guess. It was easier just to change the intHr to a Long though.

        "You only disagree because you're a moron. If you were a man of intelligence you would see that I'm obviously right." - The General Consensus

        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