Page 1 of 1

Help with Left$ command

Posted: Thu Mar 30, 2006 6:58 am
by Stephen
I've been trying to program Hangman in QBasic, and I can't get the Left$ command to work.

Here's the algorithm I'm trying to use to split the string's letters up into different variables:

numl=len(string$)
for i = 1 to numl
letter=left$(string$, i)
next i

The error it gives me says "Data type conflict error"

Posted: Fri Mar 31, 2006 9:44 am
by RyanKelly
How has the array "letter" been declared.

The left$ function returns a string typed variable.

In this statement:
t$=left$(work$,3)

If work$= "This is a test." , then t$ will be set to "Thi".

For your project, you'd probably want to use the mid$ function.

dim letter( 1 to 30) as string *1

numl=len(string$)
for i = 1 to numl
letter(i)=mid$(string$, i,1)
next i

Posted: Thu Apr 06, 2006 5:26 am
by Stephen
thanks, I figured it out on my own to use the Mid$ function, but I thought I'd post back here to see if anybody helped me.

Posted: Wed Apr 12, 2006 3:05 am
by Mac
Hey, great thread

1) Question was asked in an intelligent, complete way.

2) Answer was excellent

3) OP came back and said "Thanks"

This is the way all threads should be. But I dream on.

Mac (The old QBasic Forum of Mallard)
http://www.network54.com/Index/10167