Help with Left$ command

Please use this Board for QBasic related requests ( file research, programming, etc.)

Moderators: Administrator, Global Moderator

Post Reply
Stephen

Help with Left$ command

Post 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"
RyanKelly

Post 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
Stephen

Post 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.
Mac
Full Member
Posts: 48
Joined: Wed Jun 29, 2005 2:01 am
Contact:

Post 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
Mac
The QBasic Forum
http://www.network54.com/Forum/13959
Post Reply