Page 1 of 1

QBASIC homework assistance; again!

Posted: Sun Apr 01, 2012 3:49 pm
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

Posted: Mon Apr 02, 2012 12:22 pm
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 

Posted: Mon Apr 02, 2012 1:21 pm
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$"

?????

Posted: Mon Apr 02, 2012 2:22 pm
by moto1978
Nevermind I got it.

Thanks!