Click here to LOGIN
Information
Tutorials & Articles
Programs
Feedback
 


Forum
Add a Post
Username:   (You must log on to use your member username)Hint: Use [code] and [/code] around text to highlight it as QB code.


Subject:
Message:
Forums -> Q & A -> FORMATTING OUTPUT
JPREVARD
FORMATTING OUTPUT
Posted Jul 27 2009
PLEASE HELP ME UNDERSTAND WHAT IS WRONG WITH THE FOLLOWING CODE (AND FORMATTING IN GENERAL).  THE ERROR MESSAGE I RECEIVE IS IN THE CODE AS A COMMENT.  ALSO, IS MY "DIM AS INTEGER" LINE REDUNDANT?

BEGIN CODE:

OPEN "DATA.TXT" FOR OUTPUT AS #1

PRINT #1, "LUCK          TIME"
PRINT #1, "------        ------"

DIM LUCK AS INTEGER
DIM TIME AS INTEGER

I = 1

DO
LUCK = I * 2
TIME = I * 3
PRINT #1, USING "###           &"; LUCK; TIME
I = I + 1
LOOP UNTIL I > 20



DO

LOOP UNTIL INKEY$ <> ""

'ERROR: "TYPE MISMATCH IN MODULE HELPME AT ADDRESS 062C:00BE"

END
ass
ass
Posted Jul 28 2009
Remove the dog symbol from print #1, using = &
Dim as Integer is not redundant unless you have the common defint i in the beginning of your code
Clippy
You don't have two numbers formatted in the template
Posted Jul 28 2009
PRINT #1, USING "Luck = ### Time = ###"; LUCK; TIME

The & character denotes a full string value print. \  \ is a limited length string value.

You can use text labels in a template too.

The QBasic Station, (C) Copyright 1997-2010