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





Reply With Quote