1. Computer problem? Tech Support Guy is completely free -- paid for by advertisers and donations. Click here to join today! If you're new to Tech Support Guy, we highly recommend that you visit our Guide for New Members.

Solved: Qbasic troubple plz help

Discussion in 'Software Development' started by geek4u, Jul 27, 2009.

Thread Status:
Not open for further replies.
Advertisement
  1. geek4u

    geek4u Thread Starter

    Joined:
    Jul 27, 2009
    Messages:
    5
    Hey guys. Im trying to learn qbasic and I am having trouble running this. Keep getting the "type mismatch error". Any help would be great. Thanks.


    GOSUB SETUP
    GOSUB PROCESS
    GOSUB FINISH
    END

    SETUP:
    CLS

    PRINT "INVENTORY"
    PRINT
    PRINT "SKU WAREHOUSE DESCRIPTION COST PRICE QTY"
    PRINT
    D1$ = " \ ### \ # \ \ #### ##### ##"
    TOTAL = 0
    UNITS = 0
    READ SKU$, WAREHOUSE, DESCRIPTION$, COST, PRICE, QTY
    RETURN:
    PROCESS:
    DO UNTIL SKU$ = "DONE"
    TOTAL = TOTAL + 1
    UNITS = UNITS + 1
    PRINT USING D1$; SKU$; WAREHOUSE; DESCRIPTION$; COST; PRICE; QTY
    READ SKU$, WAREHOUSE, DESCRIPTION$, COST, PRICE, QTY
    LOOP
    DATA C101, 1, ROADHANDLER, 97.56, 125.11, 25
    DATA S209, 1, MAXDRILL, 88.76, 109.99, 6
    DATA C502, 2, TRIPOD, 32.50, 38.99, 10
    DATA S416, 2, NORMALSAW, 152.55, 179.40, 1
    DATA S812, 2, ROUTER, 48.47, 61.15, 8
    DATA T713, 2, MOCBOOT, 24.99, 29.99, 30
    DATA T814, 2, WORKBOOT, 22.99, 27.99,56
    DATA C204, 3, WHITEWALLS, 37.14, 99.95, 140
    DATA S924, 4, RADIALSAW, 376.04, 419.89, 3
    DATA TR15, 4, OXFORDSTYLE, 26.43, 31.50, 28
    DATA DONE, , , , ,
    RETURN:
    FINISH:
    PRINT "TOTALITEMS"; TOTAL
    PRINT "TOTALUNITS"; UNITS
    RETURN
    END
     
  2. TheOutcaste

    TheOutcaste

    Joined:
    Aug 7, 2007
    Messages:
    9,028
    Welcome to TSG!

    Been a while since I've used qbasic, but the problem is the format string.
    Should be something like this:
    D1$ = "\ \ # \ \ ###.## ###.## ##"
    To display a string, you use & to display the entire string. To control the length, you use \\ to position the first and last character of the string. You add spaces in between to control the length.
    The SKU$ is a 4 character string. To display it completely, you need to use \ \ (2 spaces between the slashes).
    Your Description will only display 3 characters of the description, so you need to add some spaces there. Then you can adjust the spacing of the rest so everything lines up under the column headings

    You also need to specify the decimal point, or you won't see the cents portion of the cost/price.
     
  3. Ent

    Ent Trusted Advisor

    Joined:
    Apr 11, 2009
    Messages:
    5,465
    First Name:
    Josiah
    Type mismatch came because even though it has number symbols in it, SKU$ is text and only text. Hence you Cannot have any hashes between the slashes. Fiddle this to fit your needs:

    D1$ = "\ \ # \ \ ###.## ###.## ###"
     
  4. geek4u

    geek4u Thread Starter

    Joined:
    Jul 27, 2009
    Messages:
    5
    Aweomse. Thanks guys.
     
As Seen On
As Seen On...

Welcome to Tech Support Guy!

Are you looking for the solution to your computer problem? Join our site today to ask your question. This site is completely free -- paid for by advertisers and donations.

If you're not already familiar with forums, watch our Welcome Guide to get started.

Join over 733,556 other people just like you!

Thread Status:
Not open for further replies.

Short URL to this thread: https://techguy.org/846888

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice