Respond to this messageReturn to Index
Original Message
  • Why will Val("&H") sometimes return a negative value?
    • Solitaire (Login Solitaire1)
      S
      Posted Jun 7, 2012 6:49 PM

      DIM stx AS STRING, num AS DOUBLE
      CLS
      INPUT "Enter a hex value: ", stx$
      num = VAL("&H" + stx)
      PRINT num

      For example, entering AB34 will return -21758 instead of 43828.

      How can the code be changed to display the correct answer?
    Your Name
    Your Email
    (Optional)
    Message Title
    Message Text
    Options Also send responses to my email address