Does anyone know how to count the number of characters words in a string or in anything in QBasic? I'm trying to make a hangman game and I have a list of all my words but i need to find out how to count characters for the blank spaces, you know. I would be grateful if anyone has any section of code, thanks,
Jump to Post
St$="Hello my name is John Doe"
if right$(st$)<>" " then st$=st$+" "
for k%=1 to len(st$)
if mid$(st$,k%,1)=" " then words%=words%+1
print "total characters=";characters%
print "total words=";words%
(in a sub)
declare sub getwords(st$,wds%)
xst$="Hello my name is John Doe"
print "words= ";words%
All 5 Replies
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.