Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need some help writing code for the following problems: Step 1 Write the code

ID: 3698426 • Letter: I

Question

I need some help writing code for the following problems:

   

Step 1

Write the code for the “Count Vowels” button click event. The subroutine should get the text from txtSentence and pass it to a function called CountVowels. The CountVowels should count all the vowels in the sentence( CASE INSENSITIVE ) and return the count. The “Count Vowels” button click subroutine should then display a message box with the vowel count.

Write the code for the “Count Words” button click event. This is the same as the previous problem except you should count words instead of vowels.

Write the code for the “Reverse” button click event. The subroutine should get the text from txtSentence and pass it to a function called ReverseString. The ReverseString function should reverse the string and return it. For example ReverseString( “ABC” ) should return “CBA”. The “Reverse” button click subroutine should then update the text in txtSentence with the reversed string. You cannot use the StrReverse function.


Step 2

Write the code for the “Break Apart” button click event. The subroutine should get the text from txtRecord and pass it to a subroutine called BreakApartRecord. The BreakApartRecord subroutine should break apart strRecord into fields and populate the txtField# textboxes. A field is delimited by a comma. Ignore anything after the 6th comma. The “Break Apart” button click subroutine should also clear txtRecord.

For example the ”Record #1, James E. Blues, 123 Elm Street, Cincinnati, Ohio 45242,” should be broken up into the fields as shown in the screen capture above.

Be sure to trim any leading and trailing spaces from the fields.

*** There may be less than 6 commas in the field. For example: “1, 2, 3,” Make sure you code handles this.

Write the code for the “Put Together” button click event. The subroutine should call a function PutFieldsTogether. The PutFieldsTogether function should get the text from all the txtField# textboxes and create a string by concatenating the fields together with comma&space in between each field. The PutFieldsTogether function should return this string. The “Put Together” button click subroutine should then update the text in txtRecord with the returned string. The “Put Together” button click subroutine should also clear the txtField# textboxes.

Write the code for the “Format Phone Number” button click event. The subroutine should get the text from txtPhoneNumber and pass it to a function called FormatPhoneNumber. The FormatPhoneNumber function should add parentheses around the area code and insert dashes before the prefix and trunk. The FormatPhoneNumber should return the formatted phone number. The “Format Phone Number” click event should update the text in txtFormattedPhoneNumber with that string.

Only format phone numbers that are 10 characters long and composed of digits.

Visual Basic/.NET is the language; apologies for this ommision.

Thanks!

Explanation / Answer

EXECUTABLE CODE:

)1) count vowels

Dim I As Integer

Dim nVowels As Integer

Dim Vowels As String

Dim InputString As String

Vowels = "aeiou" Console.WriteLine("Enter the string :")

InputString = Console.ReadLine()

For I = 1 To Len(InputString)

If InStr(Vowels, Mid(InputString, I, 1))

Then nVowels = nVowels + 1

End If

Next

Console.WriteLine("The total vowels are :" & nVowels)

2)count words

' Count words in this string.

Dim value As String = "To be or not to be, that is the question."

Dim count1 As Integer = CountWords(value)

' Count words again.

value = "Mary had a little lamb."

Dim count2 As Integer = CountWords(value) '

Display counts.

Console.WriteLine(count1)

Console.WriteLine(count2)

End Sub

''' <summary>

''' Use regular expression to count words.

''' </summary>

Public Function CountWords(ByVal value As String) As Integer '

Count matches.

Dim collection As MatchCollection = Regex.Matches(value, "S+")

Return collection.Count

End Function

3) Write the code for the “Reverse” button click event.

inputString = InputBox("Enter the string")

For i = Len(inputString) to 1 Step-1

var= Mid(inputString, i , 1)

reverseString = reverseString & var

Next

Msgbox reverseString