Because you are using such a large number when you day = VAL(LEFT$(number$, 8)) qbasic makes day an integer which only goes up to 32768, so if you dim day as a long it will work.
Interesting, I thought QB was 100% safe regarding variables, that it generated some kind of oveflow error when the numbers were out of limit. Newertheless it's no problem if one knows about it. Thanks!
________ Bmw V5
Last edited by nyfiken on Tue Feb 15, 2011 10:32 pm, edited 1 time in total.
It's a floating point conversion error. day is going to be SINGLE by default. VAL is irrespective of numeric type; it will return a value that fits into the data type you use with the function.
Try using PRINT day at the end of your program...you'll get an interesting result that confirms the conversion error. It's a fault with floating point values.
As a general rule, you should always DIM your variables before you use them, especially in QB where all variables are SINGLE by default.