Qbasicnews.com
Type Mismatch - Printable Version

+- Qbasicnews.com (http://qbasicnews.com/newforum)
+-- Forum: QBasic (http://qbasicnews.com/newforum/forum-4.html)
+--- Forum: QB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-11.html)
+--- Thread: Type Mismatch (/thread-10073.html)



Type Mismatch - jelamb - 12-07-2007

I get a Type Mismatch Error at the following statement in my program. The output still prints without the last data = TQTY(K). Can anyone see why I am getting this error?
LPRINT SC$(K), ID$(K); "    ";USING "####.##"; UCST(K);"    "; TQTY(K)


Re: Type Mismatch - wildcard - 12-07-2007

Is TQTY a function or an array in your code? It will help us if you post more of your code as the value of K could be the problem.


Re: Type Mismatch - jelamb - 12-08-2007

Here is more of the Code. What do you think?

500 REM PRINT RESULTS FOR THIS CATEGORY
        LPRINT PN$, " ", CAT$
        LPRINT
                FOR K = 1 TO NOR
                LPRINT SC$(K), ID$(K); "  "; USING "####.##"; UCST(K); "    "; TQTY(K)
                TCST = TCST + UCST(K) * TQTY(K)
                NEXT K
        LPRINT


Re: Type Mismatch - Moneo - 12-08-2007

(12-07-2007, 09:45 PM)jelamb link Wrote:I get a Type Mismatch Error at the following statement in my program. The output still prints without the last data = TQTY(K). Can anyone see why I am getting this error?
LPRINT SC$(K), ID$(K); "    ";USING "####.##"; UCST(K);"    "; TQTY(K)
I tried your code. You're getting the error because you can't append non-numeric data to be printed after an LPRINT USING or a PRINT USING, like the "    ".

If you need to also format TQTY(K) USING "####.##". Try the following:

LPRINT SC$(K), ID$(K); "  "; USING "####.##"; UCST(K);
LPRINT  "    ";
LPRINT USING "####.##"; TQTY(K)

Regards..... Moneo



Re: Type Mismatch - jelamb - 12-08-2007

Thanks Moneo,
That worked nicely. I am using DOSPRN and thought it might have something to do with that program but evidently not.
Thanks again.....John


Re: Type Mismatch - Ralph - 12-09-2007

Moneo:  Nicely solved!