QBASIC homework assistance; again!

If you have questions about any aspect of QBasic programming, or would like to help fellow programmers solve their problems, check out this board!

Moderators: Pete, Mods

Post Reply
moto1978
Newbie
Posts: 6
Joined: Thu Mar 08, 2012 6:27 pm

QBASIC homework assistance; again!

Post by moto1978 »

OK, any help with this one

Write a program that will produce the following output by using the LEFT$ function.

O

ON

ONO

ONOM

ONOMA

ONOMAT

ONOMATO

ONOMATOP

ONOMATOPO

ONOMATOPOE

ONOMATOPOEI

ONONMATOPOEIA

This is waht I came up with (below) but I get a mismatch error on the first X and I have no clue why or what it means

CLS
x = "ONONMATOPOEIA"

i = 1

DO UNTIL i = 13

Print Left$(x,i)

Print

i = i+1
LOOP
End

Thanks everyone
User avatar
burger2227
Veteran
Posts: 2466
Joined: Mon Aug 21, 2006 12:40 am
Location: Pittsburgh, PA

Post by burger2227 »

Code: Select all

DIM x AS STRING 'x must be a string variable or use the $ suffix after it as x$ 
CLS 
x = "ONONMATOPOEIA" 

i = 1 

DO UNTIL i = 14 'change to 14 letters or use LOOP UNTIL i = 14 instead

Print Left$(x,i) 

'Print  'remove so it doesn't scroll screen

i = i+1 
LOOP 
End 
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
moto1978
Newbie
Posts: 6
Joined: Thu Mar 08, 2012 6:27 pm

Post by moto1978 »

ok, I ran the following

CLS
x$ = "ONONMATOPOEIA"

i = 1

DO UNTIL i = 14

Print LEFT$ (x,i)
i = i+1
LOOP
End

and now get a mismatch on "LEFT$"

?????
moto1978
Newbie
Posts: 6
Joined: Thu Mar 08, 2012 6:27 pm

Post by moto1978 »

Nevermind I got it.

Thanks!
Post Reply