Question: Public Class Form1 Dim array() As Char = {a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q,
Public Class Form1 Dim array() As Char = {"a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"} Dim count(26) As Integer Dim value As String
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim cnt As Integer = 0 Dim i As Integer = 0 value = TextBox1.Text value = LCase(value) For Each ch As Char In Array cnt = 0 For Each c As Char In value If c = ch Then cnt += 1 Next count(i) = cnt i = i + 1 Next End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click Dim value1 As String Dim i As Integer = 0 Dim index As Integer = 0 value1 = TextBox2.Text value1 = CChar(value1) For Each ch As Char In Array If ch = value1 Then index = i Exit For End If i = i + 1 Next 'Dim count1 As String Dim value2 As Integer value2 = count(index) 'count1 = TypeName(CStr(value2)) TextBox3.Text = CStr(value2) End Sub End Class
Edit the code, create a form with one multi-line textbox and one button. When the user types a paragraph in the textbox then clicks the button, code will execute to calculate how many each letter of the alphabet appears in the text, where the count of each letter is saved into the array. The letter count should be case insensitive (so the text "An apple was above Allen's head" returns 6 a's) and should be done using a function (user defined). Two other controls are added, a button and a textbox (or combobox). If a combobox is used, each entry in the combobox should be one letter of the alphabet in their order. So the first entry in the combo is a, second entry is b, and so on. The user will either choose a letter from the combo, or types a letter in the textbox then clicks the second button, and the code should show the count of that letter using the position of the letter in the alphabet in the array used from button one. What should be the scope of the array so that both buttons can access it? This question does not require a textual answer - it's just a hint. How would you change your application design so that if the user makes a change in the paragraph, the count of the letter is automatically changed in the array (i.e. user does not have to click the first button to get the count). Implementing this alternate technique correctly will add 0.25 extra credit.
Pictures would be greatly appreciated!
Note: I also get an error :Option Strict On disallows implicit conversions from 'String' to 'Char'. for the array.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
