Given the following program interface and btnProcess() code, write the code for
ID: 647035 • Letter: G
Question
Given the following program interface and btnProcess() code, write the code for count() which counts the number of times the entered number occurs in the array.
Dim intNum() As Integer = {4, 5, 6, 3, 5, 4, 7, 6, 8, 7, 2, 1, 3, 2, 5, 6, 7, 4, 5, 3, 2, 8, 9, 7, 8, 6}
Private Sub btnProcess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnProcess.Click
Dim intTarget As Integer
Dim intPos As Integer
intTarget = Convert.ToInt32(TextBox1.Text)
TextBox2.Text = count(intTarget)
End Sub
Given the following program interface and btnProcess() code, write the code for count() which counts the number of times the entered number occurs in the array. Array Demonstration Enter a number Process Data Results Dim intNum() As Integer = {4, 5, 6, 3, 5, 4, 7, 6, 8, 7, 2, 1, 3, 2, 5, 6, 7, 4, 5, 3, 2, 8, 9, 7, 8, 6} Private Sub btnProcess_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnProcess.Click Dim intTarget As Integer Dim intPos As Integer intTarget = Convert.ToInt32(TextBox1.Text) TextBox2.Text = count(intTarget) End SubExplanation / Answer
int count(int target)
Dim count_num As Integer = 0
int count(int target)
Dim count_num As Integer = 0
For Each num As Integer In IntNum If num = target Then count_num = count_num + 1 Next Return count_numRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.