i want to write a code to swap the words in a string.
Input - I like cake
Output - cake I like
To do this it would be great if there is a way to determine the index of each word.Like
1- I
2- like
3- cake
Then I can swap the words.But I have no idea how to do it.
Currently I have written the code to count the number of words in a string and to get the average.
Can any one please help me with thisCode:Dim str As String = Me.t1.Text Dim strA() As String = str.Split(" ") Dim TChrs As Int32 Dim i As Int32 For i = strA.Length - 1 To 0 Step -1 TChrs += strA(i).Length Next MsgBox("Number of words = " & strA.Length) MsgBox("Average Length = " & TChrs / strA.Length)




Reply With Quote
