Remove Vowels

Romove vowels from a word.

Page 1 of 1

9 Replies - 7882 Views - Last Post: 15 July 2002 - 10:42 AM Rate Topic: -----

#1 AzNSouL  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 09-June 02

Remove Vowels

Posted 09 June 2002 - 07:31 AM

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

Is This A Good Question/Topic? 0
  • +

Replies To: Remove Vowels

#2 8Ball  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 09-June 02

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.
Was This Post Helpful? 0
  • +
  • -

#3 Quik  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 2
  • View blog
  • Posts: 3,750
  • Joined: 06-March 01

Re: Remove Vowels

Posted 09 June 2002 - 08:31 AM

Thanks for helping out 8ball.. hope it helps him.
welcome to dream.in.code
Was This Post Helpful? 0
  • +
  • -

#4 AzNSouL  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 09-June 02

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?
Was This Post Helpful? 0
  • +
  • -

#5 fyrestorm  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 10
  • View blog
  • Posts: 3,113
  • Joined: 04-April 02

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...
Was This Post Helpful? 0
  • +
  • -

#6 Noldona  Icon User is offline

  • Addicted to DIC

Reputation: 5
  • View blog
  • Posts: 1,051
  • Joined: 02-July 02

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

Attached File(s)


Was This Post Helpful? 0
  • +
  • -

#7 Cryo2k  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 08-July 02

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
Was This Post Helpful? 0
  • +
  • -

#8


Reputation: 0

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.

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.
Was This Post Helpful? 0

#9


Reputation: 0

Re: Remove Vowels

Posted 08 July 2002 - 01:52 PM

another method just hit me that might be faster:

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
Was This Post Helpful? 0

#10 Noldona  Icon User is offline

  • Addicted to DIC

Reputation: 5
  • View blog
  • Posts: 1,051
  • Joined: 02-July 02

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
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1