Results 1 to 16 of 16

Thread: Replace 5th vowel

Threaded View

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Feb 2004
    Location
    in the heart of the Mediterranean
    Posts
    1,143

    Replace 5th vowel

    Hey,

    I need to find the first letter in a message and replace it with the 5th vowel in another string. However it never gets into the condition in Red Color. Any help please ?

    I also need to keep the count of the characters in the characterarray. ???

    Code:
    Private Sub Find5vowel()
    
            Dim vowelcounter, i As Integer
            Dim characterarray() As Char
            Dim vowelarray() As Char = {"a", " A", "e", "i", "I", "o", "O", "u", " U", "E"}
            Dim strmessage1 As String
            'RandomGen1 is a string of 200 letters which has been randomized
            characterarray = RandomGen1.ToCharArray()
            For i = 1 To characterarray.Length
    
                If vowelarray = characterarray(i) Then
                    vowelcounter += 1           
                  If vowelcounter = 5 Then 
                        letter5vowel = characterarray(i)
                        strmessage1 = characterarray.ToString
                        strmessage1 = strmessage1.Replace(letter5vowel, firstmessage)
    
                    End If
                End If
            Next
    
                    MessageBox.Show(strmessage1)
    
        End Sub
    
        Private Sub Findfirst()
            Try
    
                If txtmessage.Text = String.Empty Then
                    MessageBox.Show("Message cannot be left empty!")
                Else
                    strmessage = txtmessage.Text
                    Dim messagearray() As Char
    
                    messagearray = strmessage.ToCharArray()
                    firstmessage = messagearray(0)
                    ' MessageBox.Show(firstmessage)
                End If
            Catch ex As Exception
                MessageBox.Show(ex.ToString)
            End Try
    
        End Sub
    
        Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
            Findfirst()
            Find5vowel()
    
        End Sub
    Last edited by angelica; Apr 13th, 2009 at 09:17 PM.
    ------------------------------------------------------------------------
    If an answer to your question has been helpful, then please, Rate it!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width