Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Visual Basic .NET (http://www.programmingforums.org/forum19.html)
-   -   change vowels to the letter x (http://www.programmingforums.org/showthread.php?t=13365)

boatn19 Jun 17th, 2007 4:41 PM

change vowels to the letter x
 
I am trying to change vowel letters to the letter x and numbers to the letter z and revese the word and i am ready to throw the notebook across the room, please help......

:

if vowellabel.substring(indexnum,1) = vowel then
mid(me.vowel.text) = vowel
replaceX = true
end if


Infinite Recursion Jun 17th, 2007 10:27 PM

Some things to look into:

1) For Each loops...
2) Char.IsDigit
3) Functions
4) Strings

Here is some code for you to analyze. Let me know if you have specific questions.
This probably isn't the best or easiest way to do this... but it works. I am going to leave the string reversal up to you, I suggest spending more time on this effort to better understand it.

:


Module Module1

    Sub Main()

        Dim myStr As String = "The answer is 42. Today is 6/17"

        Dim c As Char = ""
        Dim d As Char = ""

        Dim temp As String = ""

        For Each c In myStr
            d = ChangeIt(c)
            temp = String.Concat(temp, Convert.ToString(d))
        Next

        Console.WriteLine("Original: " + myStr)
        Console.WriteLine("Modified: " + temp)
        Console.WriteLine("done")
        myStr = Console.ReadLine()

    End Sub

    Public Function ChangeIt(ByVal c As Char) As Char

        Dim a As Char = ""
        Dim vowel As String = "aeiouy"

        If Char.IsDigit(c) Then
            Return "z"
        Else
            For Each a In vowel
                If Char.ToUpper(a) = Char.ToUpper(c) Then
                    Return "x"
                End If
            Next
        End If

        Return c

    End Function

End Module



:| I can't believe I just wrote code in VB... I feel sick. ;(


All times are GMT -5. The time now is 12:38 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC