Does anybody know how to write a QBasic code that:
1. INPUT "WORD"
2. Remove all VOWELS
and then
3. OUTPUT "NEW" Word
Think I need to use the following or similar in the code but I don't know how:
DIM D$(100)
C$ = "ABCDEF"
FOR J = 1 TO LEN(C$)
D$(J) = MID$(C$, J, 1)
NEXT J
DIM D$(100)
C$ = " "
FOR J = 1 TO N
C$ = C$ + D$(J)
NEXT J
Remove VowelsRomove vowels from a word.
Page 1 of 1
9 Replies - 6908 Views - Last Post: 15 July 2002 - 10:42 AM
Replies To: Remove Vowels
#2
Re: Remove Vowels
Posted 09 June 2002 - 08:15 AM
I got same problem too. I think you change the variables to strings or strings to variable. Or vice versa, something like that.
#3
Re: Remove Vowels
Posted 09 June 2002 - 08:31 AM
Thanks for helping out 8ball.. hope it helps him.
welcome to dream.in.code
welcome to dream.in.code
#4
Re: Remove Vowels
Posted 09 June 2002 - 09:22 AM
Can you give me more details about it? Hiw can you change from variables to strings?
#5
Re: Remove Vowels
Posted 09 June 2002 - 03:29 PM
correct me if i'm wrong, but doesn't the variable hold the string?
and if that is true then what i think you'd need to do is to take that string and in some way look at each of the characters one at a time, and compare them using some sort of if statement saying if $blah='a' then have a new variable that will hold the word without the vowels, you'd have to do some appending.
i hope this helps a little...
and if that is true then what i think you'd need to do is to take that string and in some way look at each of the characters one at a time, and compare them using some sort of if statement saying if $blah='a' then have a new variable that will hold the word without the vowels, you'd have to do some appending.
i hope this helps a little...
#6
Re: Remove Vowels
Posted 02 July 2002 - 06:47 PM
heres the code to remove vowels
cls
input "enter word to remove vowels from", a$
b$=""
for c=1 to len(word1$)
if mid$(a$,c,1)<>"a" and mid$(a$,c,1)<>"e" and mid$(a$,c,1)<>"i" and mid$(a$,c,1)<>"o" and mid$(a$,c,1)<>"u" and mid$(a$,c,1)<>"A" and mid$(a$,c,1)<>"E" and mid$(a$,c,1)<>"I" and mid$(a$,c,1)<>"O" and mid$(a$,c,1)<>"U" then b$=mid$(a$,c,1)
next c
end
or dl the kludge i hacked together after readin the posts above
cls
input "enter word to remove vowels from", a$
b$=""
for c=1 to len(word1$)
if mid$(a$,c,1)<>"a" and mid$(a$,c,1)<>"e" and mid$(a$,c,1)<>"i" and mid$(a$,c,1)<>"o" and mid$(a$,c,1)<>"u" and mid$(a$,c,1)<>"A" and mid$(a$,c,1)<>"E" and mid$(a$,c,1)<>"I" and mid$(a$,c,1)<>"O" and mid$(a$,c,1)<>"U" then b$=mid$(a$,c,1)
next c
end
or dl the kludge i hacked together after readin the posts above
Attached File(s)
-
Vowels.bas (674bytes)
Number of downloads: 2
#7
Re: Remove Vowels
Posted 08 July 2002 - 01:14 PM
Hi There,
Im afraid I dont have QBasic, but the following should need little or no modification.
NameIn$ is String Variable in, NameOut$ is Processed String Variable Out
Regards
Cryo
Namein$ = "Variable set from other part of Program"
Vowels$ = "AEIOUaeiou"
nameout$ = ""
For n = 1 To Len(Namein$)
letter$ = Mid$(Namein$, n, 1)
For a = 1 To Len(Vowels$)
If letter$ = Mid$(Vowels$, a, 1) Then
letter$ = ""
End If
Next a
nameout$ = nameout$ + letter$
Next n
Im afraid I dont have QBasic, but the following should need little or no modification.
NameIn$ is String Variable in, NameOut$ is Processed String Variable Out
Regards
Cryo
Namein$ = "Variable set from other part of Program"
Vowels$ = "AEIOUaeiou"
nameout$ = ""
For n = 1 To Len(Namein$)
letter$ = Mid$(Namein$, n, 1)
For a = 1 To Len(Vowels$)
If letter$ = Mid$(Vowels$, a, 1) Then
letter$ = ""
End If
Next a
nameout$ = nameout$ + letter$
Next n
#8
Re: Remove Vowels
Posted 08 July 2002 - 01:42 PM
You can do this more effectively and faster with just one for loop.
step through the input string one letter at a time with a for loop and see if the current letter is a substring of vowels.
H
P.S. my syntax might be off on the inStr function because it's been a while for VB and me. You may want to reverse the needle and haystack.
step through the input string one letter at a time with a for loop and see if the current letter is a substring of vowels.
Namein$ = "Variable set from other part of Program" Vowels$ = "AEIOUaeiou" nameout$ = "" For n = 1 To Len(Namein$) temp$ = Mid$(Namein$, n, 1) If inStr(temp$, Vowels$) = 0 Then nameout$ += temp$ End If next n
H
P.S. my syntax might be off on the inStr function because it's been a while for VB and me. You may want to reverse the needle and haystack.
#9
Re: Remove Vowels
Posted 08 July 2002 - 01:52 PM
another method just hit me that might be faster:
this code to call it
NewString$ = StripChars("There is no business like show business", "AEIOUaeiou")
H
public Function StripChars(Input$, Remove$) as string Dim n as Integer StripChars$ = Input$ for n = 1 to len(Remove$) StripChars$ = Replace$(StripChars$, mid$(Remove$, n, 1), "") next n End Function
this code to call it
NewString$ = StripChars("There is no business like show business", "AEIOUaeiou")
H
#10
Re: Remove Vowels
Posted 15 July 2002 - 10:42 AM
readin over the new post and happened to notice that in my code i made a mistake the for loop should read for c=1 to len(a$) i accidentally put word1$ in place of the a$ so if u dl my program then fix that if i didnt fix it in the code
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote





|